File size: 880 Bytes
5de10eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 = 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()