chethu commited on
Commit
e8f8ba2
·
verified ·
1 Parent(s): 196ea7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -20
app.py CHANGED
@@ -1,25 +1,30 @@
1
- from PIL import Image
2
- from predictions import get_predictions
3
- import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- def process_image(uploaded_image):
6
- return get_predictions(uploaded_image)
7
 
8
- # Define the Gradio Blocks app
9
- demo = gr.Blocks()
10
 
11
- # Define components for each step
12
- with demo:
13
- image_input = gr.Image(type="pil", label="Upload Image")
14
- processed_image_output = gr.Image(label="Processed Image with Predicted Instances")
15
- audio_output = gr.Audio(label="Generated Audio")
16
- text_output = gr.Textbox(label="Extracted Text")
17
 
18
- # Define buttons for each step
19
- process_button = gr.Button("Process Image")
 
20
 
21
- # Define actions for each button
22
- process_button.click(process_image, inputs=image_input, outputs=(processed_image_output, audio_output, text_output))
23
-
24
- # Launch the Blocks app
25
- demo.launch()
 
1
+ import streamlit as st
2
+ from PIL import Image, ImageDraw
3
+ from helper import summarize_predictions_natural_language, render_results_in_image
4
+ from transformers import pipeline
5
+ from tokenizers import Tokenizer, Encoding
6
+ from tokenizers import decoders
7
+ from tokenizers import models
8
+ from tokenizers import normalizers
9
+ from tokenizers import pre_tokenizers
10
+ from tokenizers import processors
11
+ import io
12
+ import matplotlib.pyplot as plt
13
+ import requests
14
+ import inflect
15
+ from predictions import get_predictions # Replace 'your_module' with the name of the module where your function is defined
16
 
17
+ def main():
18
+ st.title("Object Detection App")
19
 
20
+ uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
 
21
 
22
+ if uploaded_image is not None:
23
+ processed_image, text, audio = get_predictions(uploaded_image)
 
 
 
 
24
 
25
+ st.image(processed_image, caption='Processed Image', use_column_width=True)
26
+ st.write(f"Predictions: {text}")
27
+ st.audio(audio, format='audio/wav')
28
 
29
+ if __name__ == '__main__':
30
+ main()