keremsabirli commited on
Commit
0740af1
·
1 Parent(s): 7422ac8

screenshot to code ui

Browse files
Files changed (2) hide show
  1. app.py +22 -6
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,9 +1,25 @@
 
1
  import streamlit as st
 
2
 
3
- # Write a title and some text to the app:
4
- st.title('My Hugging Face Space')
5
- st.write('This is a simple Streamlit app in a Hugging Face Space!')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- # Interactive widgets:
8
- number = st.slider('Select a number', 0, 10, 5)
9
- st.write('You selected:', number)
 
1
+ from tkinter import Image
2
  import streamlit as st
3
+ from transformers import pipeline
4
 
5
+ model_name = "HuggingFaceM4/VLM_WebSight_finetuned"
6
+ image_to_code = pipeline("image-to-text", model=model_name)
7
+
8
+ st.title("Image to Code Converter")
9
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
10
+
11
+ if uploaded_file is not None:
12
+ # To see details
13
+ st.image(uploaded_file, caption='Uploaded Image.', use_column_width=True)
14
+ st.write("")
15
+ st.write("Converting image to code...")
16
+
17
+ # Convert the file to an image
18
+ image = Image.open(uploaded_file)
19
+
20
+ # Process the image
21
+ code_result = image_to_code(image)
22
+
23
+ # Display the code
24
+ st.code(code_result[0]['generated_text'])
25
 
 
 
 
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  streamlit
2
  transformers
3
- torch
 
 
1
  streamlit
2
  transformers
3
+ torch
4
+ tkinter