model2mnn / app_mnnsr.py
tumuyan2's picture
update
20ad880
raw
history blame contribute delete
893 Bytes
import gradio as gr
import os
import MNN
import numpy as np
import cv2
from PIL import Image
from mnnsr import modelTest_for_gradio
def gradio_interface(modelPath, input_image):
processed_image_np, load_time, infer_time = modelTest_for_gradio(modelPath, input_image)
processed_image_pil = Image.fromarray(cv2.cvtColor(processed_image_np, cv2.COLOR_BGR2RGB))
return processed_image_pil
# 创建Gradio界面
iface = gr.Interface(
fn=gradio_interface,
# inputs=gr.Image(type="pil", label="上传图像"),
inputs = [gr.File(label="上传MNN模型"), gr.Image(type="filepath", label="上传图像",value="./sample.jpg")],
outputs=gr.Image(type="pil", label="处理后的图像"),
title="MNN图像超分辨率处理",
description="上传图像,使用MNN模型进行超分辨率处理"
)
if __name__ == "__main__":
# 启动Gradio界面
iface.launch()