Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from transformers import AutoModel
|
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
import numpy as np
|
|
|
6 |
|
7 |
@st.cache_resource
|
8 |
def load_model():
|
@@ -13,7 +14,10 @@ def load_model():
|
|
13 |
|
14 |
@st.cache_data
|
15 |
def read_image_as_np_array(image_path):
|
16 |
-
|
|
|
|
|
|
|
17 |
image = np.array(image)
|
18 |
return image
|
19 |
|
@@ -81,7 +85,7 @@ input_text_character_matching_threshold = st.sidebar.slider('Text-character matc
|
|
81 |
|
82 |
|
83 |
if path_to_image is None:
|
84 |
-
|
85 |
|
86 |
image = read_image_as_np_array(path_to_image)
|
87 |
|
|
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
import numpy as np
|
6 |
+
import urllib.request
|
7 |
|
8 |
@st.cache_resource
|
9 |
def load_model():
|
|
|
14 |
|
15 |
@st.cache_data
|
16 |
def read_image_as_np_array(image_path):
|
17 |
+
if "http" in image_path:
|
18 |
+
image = Image.open(urllib.request.urlopen(image_path)).convert("L").convert("RGB")
|
19 |
+
else:
|
20 |
+
image = Image.open(image_path).convert("L").convert("RGB")
|
21 |
image = np.array(image)
|
22 |
return image
|
23 |
|
|
|
85 |
|
86 |
|
87 |
if path_to_image is None:
|
88 |
+
path_to_image = "https://i.imgur.com/pZqPlSR.jpeg"
|
89 |
|
90 |
image = read_image_as_np_array(path_to_image)
|
91 |
|