Spaces:
Runtime error
Runtime error
Commit
·
4b2a398
1
Parent(s):
485f23d
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from pathlib import Path
|
3 |
+
import streamlit as st
|
4 |
+
from transformers import pipeline
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
|
7 |
+
if Path(".env").is_file():
|
8 |
+
load_dotenv(".env")
|
9 |
+
st.set_page_config(layout="wide")
|
10 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
11 |
+
|
12 |
+
def img2Text(url):
|
13 |
+
image_to_text = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
|
14 |
+
text = image_to_text(url)
|
15 |
+
st.subheader(text)
|
16 |
+
print(text)
|
17 |
+
return text
|
18 |
+
img2Text(test-photo.png)
|