Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,25 +11,25 @@ def load_model():
|
|
| 11 |
return model
|
| 12 |
|
| 13 |
def main():
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
instructions = """Click an image using inbuilt camera or upload an image file"""
|
| 17 |
-
st.write(instructions)
|
| 18 |
-
|
| 19 |
-
img = None
|
| 20 |
-
pictureCam = st.camera_input('Take a picture')
|
| 21 |
-
pictureUpload = st.file_uploader('Upload An Image')
|
| 22 |
-
|
| 23 |
-
if pictureCam :
|
| 24 |
st.write('clicked image from webcam')
|
| 25 |
st.image(pictureCam)
|
| 26 |
img = Image.open(pictureCam)
|
| 27 |
-
elif pictureUpload :
|
| 28 |
st.write('uploaded image from device')
|
| 29 |
st.image(pictureUpload)
|
| 30 |
img = Image.open(pictureUpload)
|
| 31 |
-
|
| 32 |
-
if img is not None :
|
| 33 |
description = caption(img)
|
| 34 |
generated_text = description[0]['generated_text']
|
| 35 |
st.write(generated_text)
|
|
|
|
| 11 |
return model
|
| 12 |
|
| 13 |
def main():
|
| 14 |
+
caption = load_model()
|
| 15 |
+
st.title('Welcome to image to speech app')
|
| 16 |
+
instructions = """Click an image using inbuilt camera or upload an image file"""
|
| 17 |
+
st.write(instructions)
|
| 18 |
+
|
| 19 |
+
img = None
|
| 20 |
+
pictureCam = st.camera_input('Take a picture')
|
| 21 |
+
pictureUpload = st.file_uploader('Upload An Image')
|
| 22 |
+
|
| 23 |
+
if pictureCam :
|
| 24 |
st.write('clicked image from webcam')
|
| 25 |
st.image(pictureCam)
|
| 26 |
img = Image.open(pictureCam)
|
| 27 |
+
elif pictureUpload :
|
| 28 |
st.write('uploaded image from device')
|
| 29 |
st.image(pictureUpload)
|
| 30 |
img = Image.open(pictureUpload)
|
| 31 |
+
|
| 32 |
+
if img is not None :
|
| 33 |
description = caption(img)
|
| 34 |
generated_text = description[0]['generated_text']
|
| 35 |
st.write(generated_text)
|