edesaras commited on
Commit
87ecabf
1 Parent(s): 34eeac7

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. app.py +36 -0
  3. example1.jpg +3 -0
  4. example2.jpg +3 -0
  5. requirements.txt +4 -0
  6. weights.pt +3 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ example1.jpg filter=lfs diff=lfs merge=lfs -text
37
+ example2.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import numpy as np
4
+ from ultralytics import YOLO # Make sure this import works in your Hugging Face environment
5
+
6
+ # Load the model
7
+ @st.cache(allow_output_mutation=True)
8
+ def load_model():
9
+ model = YOLO("weights.pt") # Adjust path if needed
10
+ return model
11
+
12
+ model = load_model()
13
+
14
+ st.title("Circuit Sketch Recognition")
15
+
16
+ # File uploader allows user to add their own image
17
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
18
+
19
+ if uploaded_file is not None:
20
+ image = Image.open(uploaded_file).convert("RGB")
21
+ st.image(image, caption='Uploaded Image', use_column_width=True)
22
+ st.write("")
23
+ st.write("Detecting...")
24
+
25
+ # Perform inference
26
+ results = model.predict(uploaded_file)
27
+ r = results[0]
28
+ im_bgr = r.plot(conf=False, pil=True, font_size=32, line_width=2) # Returns a PIL image if pil=True
29
+ im_rgb = Image.fromarray(im_bgr[..., ::-1]) # Convert BGR to RGB
30
+
31
+ # Display the prediction
32
+ st.image(im_rgb, caption='Prediction', use_column_width=True)
33
+
34
+ # Optionally, display pre-computed example images
35
+ if st.checkbox('Show Example Results'):
36
+ st.image(['example1.jpg', 'example2.jpg'], width=300, caption=['Example 1', 'Example 2'])
example1.jpg ADDED

Git LFS Details

  • SHA256: 794b8d392509c9bd291b084059c5ece792a6a87ff08a45dfccbec77006f2e65d
  • Pointer size: 132 Bytes
  • Size of remote file: 1.1 MB
example2.jpg ADDED

Git LFS Details

  • SHA256: 87a415adccfda4190e0a37b86ad224c2c9605e1a0862cb5e1be2c4ad668772fd
  • Pointer size: 132 Bytes
  • Size of remote file: 1.19 MB
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ultralytics
2
+ stremlit
3
+ Pillow
4
+ numpy
weights.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0791285b924f954f0370a13739ca87e2569a90bf935c0afdd69797f9dc2bbf0a
3
+ size 52120385