Skip to content

Commit ccae237

Browse files
committed
Fix ktlint-detected errors
1 parent 0c041b9 commit ccae237

File tree

5 files changed

+11
-58
lines changed

5 files changed

+11
-58
lines changed

android/src/main/java/com/swmansion/rnexecutorch/SpeechToText.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ class SpeechToText(
1515
private var whisperPreprocessor = WhisperPreprocessor(reactContext)
1616
private var whisperEncoder = WhisperEncoder(reactContext)
1717
private var whisperDecoder = WhisperDecoder(reactContext)
18-
private var START_TOKEN = 50257
19-
private var EOS_TOKEN = 50256
2018

2119
companion object {
2220
const val NAME = "SpeechToText"
21+
22+
const val START_TOKEN = 50257
23+
const val EOS_TOKEN = 50256
2324
}
2425

2526
override fun loadModule(
@@ -44,10 +45,10 @@ class SpeechToText(
4445
) {
4546
val logMel = this.whisperPreprocessor.runModel(waveform)
4647
val encoding = this.whisperEncoder.runModel(logMel)
47-
val generatedTokens = mutableListOf(this.START_TOKEN)
48+
val generatedTokens = mutableListOf(START_TOKEN)
4849
var lastToken = 0
4950
Thread {
50-
while (lastToken != this.EOS_TOKEN) {
51+
while (lastToken != EOS_TOKEN) {
5152
this.whisperDecoder.setGeneratedTokens(generatedTokens)
5253
lastToken = this.whisperDecoder.runModel(encoding)
5354
emitOnToken(lastToken.toDouble())

android/src/main/java/com/swmansion/rnexecutorch/models/StyleTransferModel.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class StyleTransferModel(
2929
override fun postprocess(output: Array<EValue>): Mat {
3030
val tensor = output[0].toTensor()
3131
val modelShape = getModelImageSize()
32-
val result = ImageProcessor.EValueToMat(tensor.dataAsFloatArray, modelShape.width.toInt(), modelShape.height.toInt())
32+
val result = ImageProcessor.eValueToMat(tensor.dataAsFloatArray, modelShape.width.toInt(), modelShape.height.toInt())
3333
Imgproc.resize(result, result, originalSize)
3434
return result
3535
}

android/src/main/java/com/swmansion/rnexecutorch/models/objectDetection/SSDLiteLargeModel.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import org.opencv.core.Size
1212
import org.opencv.imgproc.Imgproc
1313
import org.pytorch.executorch.EValue
1414

15-
const val detectionScoreThreshold = .7f
16-
const val iouThreshold = .55f
15+
const val DETECTION_SCORE_THRESHOLD = .7f
16+
const val IOU_THRESHOLD = .55f
1717

1818
class SSDLiteLargeModel(
1919
reactApplicationContext: ReactApplicationContext,
@@ -52,7 +52,7 @@ class SSDLiteLargeModel(
5252
val detections: MutableList<Detection> = mutableListOf()
5353
for (idx in 0 until numel.toInt()) {
5454
val score = scores[idx]
55-
if (score < detectionScoreThreshold) {
55+
if (score < DETECTION_SCORE_THRESHOLD) {
5656
continue
5757
}
5858
val bbox =
@@ -68,7 +68,7 @@ class SSDLiteLargeModel(
6868
)
6969
}
7070

71-
val detectionsPostNms = nms(detections, iouThreshold)
71+
val detectionsPostNms = nms(detections, IOU_THRESHOLD)
7272
return detectionsPostNms.toTypedArray()
7373
}
7474
}

android/src/main/java/com/swmansion/rnexecutorch/utils/ImageProcessor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ImageProcessor {
7272
)
7373
}
7474

75-
fun EValueToMat(
75+
fun eValueToMat(
7676
array: FloatArray,
7777
width: Int,
7878
height: Int,

android/src/main/java/com/swmansion/rnexecutorch/utils/ProgressResponseBody.kt

-48
This file was deleted.

0 commit comments

Comments
 (0)