Spaces:
Runtime error
Runtime error
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: π’
|
|
4 |
colorFrom: purple
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: purple
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.44.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
CHANGED
@@ -4,14 +4,13 @@ import argparse
|
|
4 |
import gradio as gr
|
5 |
import spaces
|
6 |
|
7 |
-
|
8 |
|
9 |
@spaces.GPU(duration=60)
|
10 |
def predict(input_img):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# return contents
|
15 |
|
16 |
def get_image_path_list(folder_name):
|
17 |
image_basename_list = os.listdir(folder_name)
|
@@ -90,11 +89,11 @@ css = """
|
|
90 |
"""
|
91 |
|
92 |
if __name__ == "__main__":
|
93 |
-
|
94 |
-
|
95 |
|
96 |
-
|
97 |
-
|
98 |
|
99 |
with gr.Blocks(css=css) as demo:
|
100 |
gr.Markdown(title)
|
|
|
4 |
import gradio as gr
|
5 |
import spaces
|
6 |
|
7 |
+
from utils import Image2Text
|
8 |
|
9 |
@spaces.GPU(duration=60)
|
10 |
def predict(input_img):
|
11 |
+
global image_to_text
|
12 |
+
contents = image_to_text.get_text(input_img, num_beams=4)
|
13 |
+
return contents
|
|
|
14 |
|
15 |
def get_image_path_list(folder_name):
|
16 |
image_basename_list = os.listdir(folder_name)
|
|
|
89 |
"""
|
90 |
|
91 |
if __name__ == "__main__":
|
92 |
+
repo_id = os.getenv('MODEL_REPO_ID')
|
93 |
+
hf_token = os.environ.get("HF_TOKEN")
|
94 |
|
95 |
+
device = "cuda"
|
96 |
+
image_to_text = Image2Text(repo_id, hf_token=hf_token, device=device)
|
97 |
|
98 |
with gr.Blocks(css=css) as demo:
|
99 |
gr.Markdown(title)
|