Format code

This commit is contained in:
Ming Ming 2022-06-16 23:04:22 +08:00
parent 12542856a0
commit 8805861ea4

View file

@ -528,36 +528,35 @@ private open class ImageProcessorCommandTask(context: Context) :
handleCancel() handleCancel()
return try { return try {
val fileUri = Uri.fromFile(file) val fileUri = Uri.fromFile(file)
val output = measureTime( val output = measureTime(TAG, "[handleCommand] Elapsed time", {
TAG, "[handleCommand] Elapsed time", { when (cmd.method) {
when (cmd.method) { ImageProcessorService.METHOD_ZERO_DCE -> ZeroDce(
ImageProcessorService.METHOD_ZERO_DCE -> ZeroDce( context, cmd.maxWidth, cmd.maxHeight,
context, cmd.maxWidth, cmd.maxHeight, cmd.args["iteration"] as? Int ?: 8
cmd.args["iteration"] as? Int ?: 8 ).infer(
).infer( fileUri
fileUri )
)
ImageProcessorService.METHOD_DEEP_LAP_PORTRAIT -> DeepLab3Portrait( ImageProcessorService.METHOD_DEEP_LAP_PORTRAIT -> DeepLab3Portrait(
context, cmd.maxWidth, cmd.maxHeight, context, cmd.maxWidth, cmd.maxHeight,
cmd.args["radius"] as? Int ?: 16 cmd.args["radius"] as? Int ?: 16
).infer(fileUri) ).infer(fileUri)
ImageProcessorService.METHOD_ESRGAN -> Esrgan( ImageProcessorService.METHOD_ESRGAN -> Esrgan(
context, cmd.maxWidth, cmd.maxHeight context, cmd.maxWidth, cmd.maxHeight
).infer(fileUri) ).infer(fileUri)
ImageProcessorService.METHOD_ARBITRARY_STYLE_TRANSFER -> ArbitraryStyleTransfer( ImageProcessorService.METHOD_ARBITRARY_STYLE_TRANSFER -> ArbitraryStyleTransfer(
context, cmd.maxWidth, cmd.maxHeight, context, cmd.maxWidth, cmd.maxHeight,
cmd.args["styleUri"] as Uri, cmd.args["styleUri"] as Uri,
cmd.args["weight"] as Float cmd.args["weight"] as Float
).infer(fileUri) ).infer(fileUri)
else -> throw IllegalArgumentException( else -> throw IllegalArgumentException(
"Unknown method: ${cmd.method}" "Unknown method: ${cmd.method}"
) )
} }
}) })
handleCancel() handleCancel()
saveBitmap(output, cmd.filename, file) saveBitmap(output, cmd.filename, file)
} finally { } finally {