Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,10 @@ model = BlipForConditionalGeneration.from_pretrained(model_id)
|
|
9 |
processor = BlipProcessor.from_pretrained(model_id)
|
10 |
|
11 |
def launch(input):
|
|
|
12 |
image = Image.open(requests.get(input, stream=True).raw).convert('RGB')
|
|
|
|
|
13 |
inputs = processor(image, return_tensors="pt")
|
14 |
out = model.generate(**inputs)
|
15 |
generated_text = processor.decode(out[0], skip_special_tokens=True)
|
@@ -19,7 +22,9 @@ def launch(input):
|
|
19 |
sufijo = " top view, flat"
|
20 |
result = f"{prefijo}{generated_text}{sufijo}"
|
21 |
|
22 |
-
|
|
|
23 |
|
24 |
-
|
|
|
25 |
iface.launch()
|
|
|
9 |
processor = BlipProcessor.from_pretrained(model_id)
|
10 |
|
11 |
def launch(input):
|
12 |
+
# Obtener la imagen desde la URL de entrada
|
13 |
image = Image.open(requests.get(input, stream=True).raw).convert('RGB')
|
14 |
+
|
15 |
+
# Procesar la imagen y generar el texto
|
16 |
inputs = processor(image, return_tensors="pt")
|
17 |
out = model.generate(**inputs)
|
18 |
generated_text = processor.decode(out[0], skip_special_tokens=True)
|
|
|
22 |
sufijo = " top view, flat"
|
23 |
result = f"{prefijo}{generated_text}{sufijo}"
|
24 |
|
25 |
+
# Devolver tanto la imagen como el texto
|
26 |
+
return image, result
|
27 |
|
28 |
+
# Cambiar la configuraci贸n de Gradio para que la salida incluya imagen y texto
|
29 |
+
iface = gr.Interface(launch, inputs="text", outputs=["image", "text"])
|
30 |
iface.launch()
|