mkoot007 commited on
Commit
1a63a37
·
1 Parent(s): 8da0b8c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import torch
4
+ from transformers import pipeline
5
+
6
+ # Initialize the Hugging Face model for image captioning
7
+ image_captioning_model = pipeline("image-captioning")
8
+
9
+ # Streamlit app title and description
10
+ st.title("Image Information Extractor")
11
+ st.write("Upload an image, and this app will extract information from it.")
12
+
13
+ # Upload image
14
+ image = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
15
+
16
+ if image:
17
+ # Display the uploaded image
18
+ st.image(image, use_column_width=True, caption="Uploaded Image")
19
+
20
+ # Process the image and extract information
21
+ image = Image.open(image)
22
+ st.write("Extracting information from the image...")
23
+
24
+ # Use the image captioning model to generate a description
25
+ captions = image_captioning_model(image)
26
+
27
+ # Display the image description
28
+ st.write("Image Description:")
29
+ for caption in captions:
30
+ st.write(caption["caption"])
31
+
32
+ # You can add more processing or explanations here if needed
33
+
34
+ st.sidebar.text("Built with ❤️ by Your Moneeb")