Spaces:
Sleeping
Sleeping
File size: 998 Bytes
e0b5df0 d98be03 861267f d98be03 ca89542 d98be03 861267f efba06b 861267f 3d2e22b efba06b 3d2e22b ca89542 |
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 32 33 34 |
import gradio as gr
import os
import shutil
# Crie a pasta 'imagens' se ela não existir
if not os.path.exists('imagens'):
os.makedirs('imagens')
def save_image(image_path):
# Verifica se o caminho é uma lista (às vezes o Gradio retorna uma lista)
if isinstance(image_path, list):
image_path = image_path[0]
image_name = os.path.basename(image_path)
target_path = os.path.join('imagens', image_name)
shutil.move(image_path, target_path)
url = f"https://13ze-cs.hf.space/file/13ze-cs/imagens/{image_name}"
return target_path, url, target_path
def display_image(image_path):
return image_path
# Interface Gradio
with gr.Blocks() as demo:
gr.Markdown("# Envie uma imagem")
file_input = gr.File(label="Selecione uma imagem", type="filepath")
image_output = gr.Image()
url_output = gr.Textbox()
submit_btn = gr.Button("Enviar")
submit_btn.click(save_image, inputs=file_input, outputs=[image_output, url_output])
demo.launch()
|