You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.7 KiB

5 months ago
import gradio as gr
from img_enhancement import Image_enhancement
"""1.1 对图像进行几何处理:图片旋转、图片缩放"""
# 类实例化
img_enhance = Image_enhancement()
def img_handle_1():
def pridict_1(query_image=None,angle=30):
img_roate = img_enhance.roate(query_image, angle)
return img_roate
def pridict_2(query_image=None,w=224,h=224):
img_resized = img_enhance.resize(query_image, int(w), int(h))
return img_resized
title = "<h1 align='center'>图像处理操作1:几何处理</h1>"
description = "1.对图像进行几何处理:图片旋转、图片缩放" # "频率像素点操作:模糊、锐化、添加噪声、边缘检测等操作"
with gr.Blocks() as demo:
gr.Markdown(title)
gr.Markdown(description)
with gr.Row():
with gr.Column(scale=1):
img = gr.components.Image(label="图片")
angle_num = gr.components.Slider(minimum=0, maximum=360, step=5, value=45, label="选择要旋转的角度")
btn_1 = gr.Button("图片旋转", )
w = gr.Number(label="图片缩放宽为:",value=224)
h = gr.Number(label="图片缩放高为:", value=224)
btn_2 = gr.Button("图片缩放", )
with gr.Column(scale=1):
out = gr.components.Image(label="处理后的图片为", height="auto")
btn_1.click(fn=pridict_1, inputs=[img, angle_num], outputs=out)
btn_2.click(fn=pridict_2, inputs=[img, w,h], outputs=out)
return demo
if __name__ == "__main__":
with gr.TabbedInterface(
[img_handle_1()],
["图像处理1:几何处理"],
) as demo:
demo.launch()