Spaces:
Runtime error
Runtime error
Commit
·
e48b085
1
Parent(s):
cdc6975
Subindo arquivos113
Browse files- app.py +9 -1
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from PIL import Image
|
|
@@ -5,6 +6,13 @@ from gtts import gTTS
|
|
| 5 |
import numpy as np
|
| 6 |
import cv2
|
| 7 |
from transformers import BlipProcessor, BlipForConditionalGeneration, MarianMTModel, MarianTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Carregar o modelo YOLOv5
|
| 10 |
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
|
|
@@ -74,7 +82,7 @@ def process_image(image):
|
|
| 74 |
# Carregar imagem de exemplo diretamente do código
|
| 75 |
example_image_path = "example1.JPG"
|
| 76 |
|
| 77 |
-
# Interface
|
| 78 |
iface = gr.Interface(
|
| 79 |
fn=process_image,
|
| 80 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
from PIL import Image
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
import cv2
|
| 8 |
from transformers import BlipProcessor, BlipForConditionalGeneration, MarianMTModel, MarianTokenizer
|
| 9 |
+
from huggingface_hub import login
|
| 10 |
+
|
| 11 |
+
# Ler o token da variável de ambiente
|
| 12 |
+
hf_token = os.getenv("HUGGINGFACE_TOKEN")
|
| 13 |
+
|
| 14 |
+
if hf_token:
|
| 15 |
+
login(token=hf_token)
|
| 16 |
|
| 17 |
# Carregar o modelo YOLOv5
|
| 18 |
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
|
|
|
|
| 82 |
# Carregar imagem de exemplo diretamente do código
|
| 83 |
example_image_path = "example1.JPG"
|
| 84 |
|
| 85 |
+
# Interface Gradio
|
| 86 |
iface = gr.Interface(
|
| 87 |
fn=process_image,
|
| 88 |
inputs=gr.Image(type="pil"),
|
requirements.txt
CHANGED
|
@@ -6,3 +6,5 @@ opencv-python
|
|
| 6 |
transformers
|
| 7 |
gtts
|
| 8 |
sentencepiece
|
|
|
|
|
|
|
|
|
| 6 |
transformers
|
| 7 |
gtts
|
| 8 |
sentencepiece
|
| 9 |
+
huggingface_hub
|
| 10 |
+
|