Update app.py
Browse files
app.py
CHANGED
@@ -146,10 +146,10 @@ def login_section():
|
|
146 |
|
147 |
|
148 |
|
149 |
-
def predict(cap_col, target_language):
|
150 |
captions = []
|
151 |
-
|
152 |
-
pred_caption = image_to_text(
|
153 |
|
154 |
cap_col.markdown('#### Predicted Captions:')
|
155 |
translated_caption = translate(pred_caption, target_language)
|
@@ -173,8 +173,7 @@ def generate_caption_section():
|
|
173 |
# Image URL input
|
174 |
img_url = st.text_input(label='Enter Image URL')
|
175 |
|
176 |
-
|
177 |
-
img_upload = st.file_uploader(label='Upload Image', type=['jpg', 'png', 'jpeg'])
|
178 |
|
179 |
# Language selection dropdown
|
180 |
|
@@ -187,20 +186,14 @@ def generate_caption_section():
|
|
187 |
img = img.convert('RGB')
|
188 |
col1.image(img, caption="Input Image", use_column_width=True)
|
189 |
img.save('tmp.jpg')
|
190 |
-
predict(col2, target_language)
|
191 |
|
192 |
st.markdown('<center style="opacity: 70%">OR</center>', unsafe_allow_html=True)
|
193 |
|
194 |
-
|
195 |
-
img = img_upload.read()
|
196 |
-
img = Image.open(io.BytesIO(img))
|
197 |
-
img = img.convert('RGB')
|
198 |
-
col1.image(img, caption="Input Image", use_column_width=True)
|
199 |
-
img.save('tmp.jpg')
|
200 |
-
predict(col2, target_language)
|
201 |
|
202 |
# Remove temporary image file
|
203 |
-
if img_url
|
204 |
os.remove('tmp.jpg')
|
205 |
|
206 |
def main():
|
|
|
146 |
|
147 |
|
148 |
|
149 |
+
def predict(cap_col, img, target_language):
|
150 |
captions = []
|
151 |
+
|
152 |
+
pred_caption = image_to_text(img)
|
153 |
|
154 |
cap_col.markdown('#### Predicted Captions:')
|
155 |
translated_caption = translate(pred_caption, target_language)
|
|
|
173 |
# Image URL input
|
174 |
img_url = st.text_input(label='Enter Image URL')
|
175 |
|
176 |
+
|
|
|
177 |
|
178 |
# Language selection dropdown
|
179 |
|
|
|
186 |
img = img.convert('RGB')
|
187 |
col1.image(img, caption="Input Image", use_column_width=True)
|
188 |
img.save('tmp.jpg')
|
189 |
+
predict(col2, img, target_language)
|
190 |
|
191 |
st.markdown('<center style="opacity: 70%">OR</center>', unsafe_allow_html=True)
|
192 |
|
193 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
# Remove temporary image file
|
196 |
+
if img_url
|
197 |
os.remove('tmp.jpg')
|
198 |
|
199 |
def main():
|