Spaces:
Configuration error
Configuration error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Загружаем модель
|
| 5 |
+
pipe = pipeline("image-to-text", model="deepseek-ai/DeepSeek-VL2-Small")
|
| 6 |
+
|
| 7 |
+
def predict(image):
|
| 8 |
+
result = pipe(image)
|
| 9 |
+
return result[0]['generated_text'] if isinstance(result, list) else result
|
| 10 |
+
|
| 11 |
+
# Интерфейс для ввода картинки
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=predict,
|
| 14 |
+
inputs=gr.Image(type="pil"),
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="DeepSeek Image-to-Text Generator",
|
| 17 |
+
description="Генерация описания по изображению через DeepSeek-VL2-Small"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Запуск
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
iface.launch()
|