Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,8 @@ API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
|
|
| 20 |
|
| 21 |
def translate(prompt_ , to_lang):
|
| 22 |
input_prompt = "translate this"
|
| 23 |
-
seed = 42
|
|
|
|
| 24 |
prompt = f"Instruction : Given an English input sentence translate it into {to_lang} sentence. \n input : \"{prompt_}\" \n {to_lang} : "
|
| 25 |
if len(prompt) == 0:
|
| 26 |
prompt = input_prompt
|
|
@@ -153,8 +154,11 @@ def predict(cap_col, img, target_language):
|
|
| 153 |
pred_caption = image_to_text(img)
|
| 154 |
|
| 155 |
cap_col.markdown('#### Predicted Captions:')
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
# for _ in range(4):
|
| 160 |
#pred_caption = image_to_text(img)
|
|
@@ -179,7 +183,7 @@ def generate_caption_section():
|
|
| 179 |
# Language selection dropdown
|
| 180 |
|
| 181 |
|
| 182 |
-
target_language = st.selectbox('Select Target Language', ['
|
| 183 |
|
| 184 |
# Process image and generate captions
|
| 185 |
if img_url:
|
|
|
|
| 20 |
|
| 21 |
def translate(prompt_ , to_lang):
|
| 22 |
input_prompt = "translate this"
|
| 23 |
+
seed = 42
|
| 24 |
+
|
| 25 |
prompt = f"Instruction : Given an English input sentence translate it into {to_lang} sentence. \n input : \"{prompt_}\" \n {to_lang} : "
|
| 26 |
if len(prompt) == 0:
|
| 27 |
prompt = input_prompt
|
|
|
|
| 154 |
pred_caption = image_to_text(img)
|
| 155 |
|
| 156 |
cap_col.markdown('#### Predicted Captions:')
|
| 157 |
+
if target_language == 'English':
|
| 158 |
+
captions.append(pred_caption)
|
| 159 |
+
else:
|
| 160 |
+
translated_caption = translate(pred_caption, target_language)
|
| 161 |
+
captions.append(translated_caption)
|
| 162 |
|
| 163 |
# for _ in range(4):
|
| 164 |
#pred_caption = image_to_text(img)
|
|
|
|
| 183 |
# Language selection dropdown
|
| 184 |
|
| 185 |
|
| 186 |
+
target_language = st.selectbox('Select Target Language', ['English', 'Spanish', 'Hindi', 'Italian'], index=0)
|
| 187 |
|
| 188 |
# Process image and generate captions
|
| 189 |
if img_url:
|