Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,6 @@ import gradio as gr
|
|
| 2 |
import os
|
| 3 |
import shutil
|
| 4 |
|
| 5 |
-
# Defina o nome do seu Hugging Face Space
|
| 6 |
-
SPACE_NAME = "seu-nome-de-usuario/seu-nome-do-space"
|
| 7 |
-
|
| 8 |
-
# Crie a pasta 'imagens' se ela não existir
|
| 9 |
-
if not os.path.exists('imagens'):
|
| 10 |
-
os.makedirs('imagens')
|
| 11 |
-
|
| 12 |
-
def save_image(image_path):import gradio as gr
|
| 13 |
-
import os
|
| 14 |
-
import shutil
|
| 15 |
-
|
| 16 |
# Crie a pasta 'imagens' se ela não existir
|
| 17 |
if not os.path.exists('imagens'):
|
| 18 |
os.makedirs('imagens')
|
|
@@ -24,9 +13,6 @@ def save_image(image_path):
|
|
| 24 |
url = f"https://13ze-cs.hf.space/file/13ze-cs/imagens/{image_name}"
|
| 25 |
return target_path, url
|
| 26 |
|
| 27 |
-
def display_image(image_path):
|
| 28 |
-
return image_path
|
| 29 |
-
|
| 30 |
# Interface Gradio
|
| 31 |
with gr.Blocks() as demo:
|
| 32 |
gr.Markdown("# Envie uma imagem")
|
|
@@ -37,22 +23,4 @@ with gr.Blocks() as demo:
|
|
| 37 |
|
| 38 |
submit_btn.click(save_image, inputs=file_input, outputs=[image_output, url_output])
|
| 39 |
|
| 40 |
-
demo.launch()
|
| 41 |
-
|
| 42 |
-
image_name = os.path.basename(image_path)
|
| 43 |
-
target_path = os.path.join('imagens', image_name)
|
| 44 |
-
shutil.move(image_path, target_path)
|
| 45 |
-
|
| 46 |
-
# Gera a URL completa
|
| 47 |
-
url = f"https://{SPACE_NAME}.hf.space/imagens/{image_name}"
|
| 48 |
-
return f"Imagem salva em: {url}"
|
| 49 |
-
|
| 50 |
-
# Interface Gradio
|
| 51 |
-
with gr.Blocks() as demo:
|
| 52 |
-
gr.Markdown("# Envie uma imagem")
|
| 53 |
-
file_input = gr.File(label="Selecione uma imagem", type="filepath")
|
| 54 |
-
output = gr.Textbox()
|
| 55 |
-
submit_btn = gr.Button("Enviar")
|
| 56 |
-
submit_btn.click(save_image, inputs=file_input, outputs=output)
|
| 57 |
-
|
| 58 |
demo.launch()
|
|
|
|
| 2 |
import os
|
| 3 |
import shutil
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Crie a pasta 'imagens' se ela não existir
|
| 6 |
if not os.path.exists('imagens'):
|
| 7 |
os.makedirs('imagens')
|
|
|
|
| 13 |
url = f"https://13ze-cs.hf.space/file/13ze-cs/imagens/{image_name}"
|
| 14 |
return target_path, url
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
# Interface Gradio
|
| 17 |
with gr.Blocks() as demo:
|
| 18 |
gr.Markdown("# Envie uma imagem")
|
|
|
|
| 23 |
|
| 24 |
submit_btn.click(save_image, inputs=file_input, outputs=[image_output, url_output])
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
demo.launch()
|