sanchastar commited on
Commit
39b4444
·
verified ·
1 Parent(s): 51dff67

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Загружаем модель BLIP2 (умеет генерировать описания изображений)
5
+ pipe = pipeline("image-to-text", model="paragon-AI/blip2-image-to-text")
6
+
7
+ def describe(image):
8
+ result = pipe(image)[0]['generated_text']
9
+ return result
10
+
11
+ demo = gr.Interface(
12
+ fn=describe,
13
+ inputs=gr.Image(type="pil"),
14
+ outputs="text",
15
+ title="Автоматическое описание изображений",
16
+ description="Загрузи картинку, и модель создаст текстовое описание."
17
+ )
18
+
19
+ if __name__ == "__main__":
20
+ demo.launch()