hiraltalsaniya commited on
Commit
9bcc172
1 Parent(s): 7c0daf0

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +49 -0
  2. best.pt +3 -0
  3. requirements.txt +38 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from huggingface_hub import hf_hub_download
4
+ from PIL import Image
5
+
6
+ REPO_ID = "hiraltalsaniya/YOLOv7"
7
+ FILENAME = "best.pt"
8
+
9
+
10
+ yolov7_custom_weights = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
11
+
12
+ model = torch.hub.load('Owaiskhan9654/yolov7-1:main',model='custom', path_or_model=yolov7_custom_weights, force_reload=True) # My Github repository https://github.com/Owaiskhan9654
13
+
14
+ def object_detection(im, size=416):
15
+ results = model(im)
16
+ results.render()
17
+ return Image.fromarray(results.imgs[0])
18
+
19
+ title = "Yolov7 Custom"
20
+
21
+ image = gr.inputs.Image(shape=(416, 416), image_mode="RGB", source="upload", label="Upload Image", optional=False)
22
+ outputs = gr.outputs.Image(type="pil", label="Output Image")
23
+
24
+ Custom_description="<center>Custom Training Performed on Kaggle <a href='https://www.kaggle.com/code/owaiskhan9654/training-yolov7-on-kaggle-on-custom-dataset/notebook' style='text-decoration: underline' target='_blank'>Link</a> </center><br> <center>Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors </center> <br> <b>1st</b> class is for Person Detected<br><b>2nd</b> class is for Car Detected"
25
+
26
+ Footer = (
27
+ "<center>Model Trained by: Owais Ahmad Data Scientist at <b> Thoucentric </b> <a href=\"https://www.linkedin.com/in/owaiskhan9654/\">Visit Profile</a> <br></center>"
28
+
29
+ "<center> Model Trained Kaggle Kernel <a href=\"https://www.kaggle.com/code/owaiskhan9654/training-yolov7-on-kaggle-on-custom-dataset/notebook\">Link</a> <br></center>"
30
+
31
+ "<center> Kaggle Profile <a href=\"https://www.kaggle.com/owaiskhan9654\">Link</a> <br> </center>"
32
+
33
+ "<center> HuggingFace🤗 Model Deployed Repository <a href=\"https://huggingface.co/owaiskha9654/Yolov7_Custom_Object_Detection\">Link</a> <br></center>"
34
+ )
35
+
36
+ examples1=[["Image1.jpeg"],["Image2.jpeg"],["Image3.jpeg"],["Image4.jpeg"],["Image5.jpeg"],["Image6.jpeg"],["horses.jpeg"],["horses.jpeg"]]
37
+
38
+ Top_Title="<center>Yolov7 🚀 Custom Trained by <a href='https://www.linkedin.com/in/owaiskhan9654/' style='text-decoration: underline' target='_blank'>Owais Ahmad </center></a>🚗Car and 👦Person Detection"
39
+ css = ".output-image, .input-image {height: 50rem !important; width: 100% !important;}"
40
+ css = ".image-preview {height: auto !important;}"
41
+
42
+ gr.Interface(
43
+ fn=object_detection,
44
+ inputs=image,
45
+ outputs=outputs,
46
+ title=Top_Title,
47
+ description=Custom_description,
48
+ article=Footer,
49
+ examples=[["car-person-2.jpg"], ["car-person-2.jpg"]]).launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:170c1d717b178361f5ac6c0fab129038132ab023f621ecbc5a55593872e08807
3
+ size 74821193
requirements.txt ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Yolov7 WongKinYiu Requirements
2
+
3
+ # Usage: pip install -r requirements.txt
4
+
5
+ # Base ----------------------------------------
6
+ matplotlib>=3.2.2
7
+ numpy>=1.18.5
8
+ opencv-python>=4.1.1
9
+ Pillow>=7.1.2
10
+ PyYAML>=5.3.1
11
+ requests>=2.23.0
12
+ scipy>=1.4.1
13
+ torch>=1.7.0,!=1.12.0
14
+ torchvision>=0.8.1,!=0.13.0
15
+ tqdm>=4.41.0
16
+ protobuf<4.21.3
17
+
18
+ # Logging -------------------------------------
19
+ tensorboard>=2.4.1
20
+ # wandb
21
+
22
+ # Plotting ------------------------------------
23
+ pandas>=1.1.4
24
+ seaborn>=0.11.0
25
+
26
+ # Export --------------------------------------
27
+ # coremltools>=4.1 # CoreML export
28
+ # onnx>=1.9.0 # ONNX export
29
+ # onnx-simplifier>=0.3.6 # ONNX simplifier
30
+ # scikit-learn==0.19.2 # CoreML quantization
31
+ # tensorflow>=2.4.1 # TFLite export
32
+ # tensorflowjs>=3.9.0 # TF.js export
33
+ # openvino-dev # OpenVINO export
34
+
35
+ # Extras --------------------------------------
36
+ ipython # interactive notebook
37
+ psutil # system utilization
38
+ thop # FLOPs computation