|
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 |
|
|
|
|
|
iface = gr.Interface( |
|
fn=gradio_interface, |
|
|
|
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__": |
|
|
|
iface.launch() |
|
|