Spaces:
Running
Running
File size: 1,046 Bytes
43c3477 |
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 30 31 |
import gradio as gr
from PIL import Image
import json
def extract_metadata(image):
if image is None:
return "η»εγιΈζγγγ¦γγΎγγγ"
try:
img = Image.open(image)
metadata = img.info # Pillowγ―PNG Infoγͺγ©γγγγ«δΏζ
if not metadata:
return "γ‘γΏγγΌγΏγθ¦γ€γγγΎγγγ§γγγ"
return json.dumps(metadata, indent=2, ensure_ascii=False)
except Exception as e:
return f"γ¨γ©γΌ: {str(e)}"
with gr.Blocks() as demo:
gr.Markdown("## Stable Diffusionη»εγγγγγ³γγζ
ε ±ζ½εΊ")
with gr.Row():
with gr.Column():
input_image = gr.Image(type="filepath", label="η»εγγ’γγγγΌγ")
extract_button = gr.Button("γγγ³γγγζ½εΊ")
with gr.Column():
output_text = gr.Textbox(label="ζ½εΊη΅ζ", lines=20)
extract_button.click(fn=extract_metadata, inputs=input_image, outputs=output_text)
if __name__ == "__main__":
demo.launch()
|