File size: 442 Bytes
d3a1278
 
 
5e250bb
d3a1278
 
 
 
 
 
5e250bb
bd22091
5e250bb
 
 
 
3c25726
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
from pathlib import Path
import streamlit as st
from transformers import pipeline
from dotenv import load_dotenv

if Path(".env").is_file():
    load_dotenv(".env")
st.set_page_config(layout="wide")
HF_TOKEN = os.getenv("HF_TOKEN")

def img2Text(url):
    image_to_text = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
    text = image_to_text(url)
    print(text)
    return text
img2Text(test-photo.png)