imes / app.py
sanchastar's picture
Create app.py
39b4444 verified
raw
history blame contribute delete
672 Bytes
import gradio as gr
from transformers import pipeline
# Загружаем модель BLIP2 (умеет генерировать описания изображений)
pipe = pipeline("image-to-text", model="paragon-AI/blip2-image-to-text")
def describe(image):
result = pipe(image)[0]['generated_text']
return result
demo = gr.Interface(
fn=describe,
inputs=gr.Image(type="pil"),
outputs="text",
title="Автоматическое описание изображений",
description="Загрузи картинку, и модель создаст текстовое описание."
)
if __name__ == "__main__":
demo.launch()