Skip to content

Commit

Permalink
#11 모델 변경, 이미지 사이즈가 너무 커서 메인 스레드가 블락되나..
Browse files Browse the repository at this point in the history
  • Loading branch information
comye1 committed Mar 3, 2022
1 parent abeb32f commit 0895cba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.util.Log
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageProxy
import com.comye1.dontsleepdriver.ml.SleepModel
import org.tensorflow.lite.DataType
import org.tensorflow.lite.support.image.ImageProcessor
import org.tensorflow.lite.support.image.TensorImage
import org.tensorflow.lite.support.image.ops.ResizeOp
Expand All @@ -24,7 +25,8 @@ class SleepAnalyzer(context: Context, private val listener: (String) -> Unit) :
override fun analyze(image: ImageProxy) {
Log.d("SleepAnalyzer", "image : ${image.image.toString()}")
if (image.image != null) {
var tfImage = TensorImage.fromBitmap(image.image!!.toBitmap())
var tfImage = TensorImage(DataType.FLOAT32)
tfImage.load(image.image!!.toBitmap())
tfImage = imageProcessor.process(tfImage) // image resize
Log.d("SleepAnalyzer", tfImage.tensorBuffer.shape.toString())

Expand Down Expand Up @@ -64,7 +66,7 @@ class SleepAnalyzer(context: Context, private val listener: (String) -> Unit) :
// image resize processor
private val imageProcessor =
ImageProcessor.Builder()
.add(ResizeOp(224, 224, ResizeOp.ResizeMethod.BILINEAR))
.add(ResizeOp(640, 640, ResizeOp.ResizeMethod.BILINEAR))
.build()
}

Binary file removed app/src/main/ml/SLeepModel1.tflite
Binary file not shown.
Binary file modified app/src/main/ml/SleepModel.tflite
Binary file not shown.

0 comments on commit 0895cba

Please sign in to comment.