File size: 1,737 Bytes
9bcc172
 
 
 
 
d668599
9bcc172
 
 
a6f7bad
9bcc172
0384003
9bcc172
 
 
 
 
 
 
 
 
 
d668599
9bcc172
 
d668599
9bcc172
 
 
d668599
9bcc172
 
 
 
 
 
 
 
 
 
3f7cfd4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import torch
import gradio as gr
from huggingface_hub import hf_hub_download
from PIL import Image

REPO_ID = "hiraltalsaniya/YOLOv7"
FILENAME = "best.pt"


yolov7_custom_weights = hf_hub_download(repo_id=REPO_ID, filename=FILENAME,repo_type='space')

model = torch.hub.load('WongKinYiu/yolov7:main',model='custom', path_or_model=yolov7_custom_weights, force_reload=True)
def object_detection(im, size=416):
    results = model(im) 
    results.render()  
    return Image.fromarray(results.imgs[0])

title = "Yolov7 Custom"

image = gr.inputs.Image(shape=(416, 416), image_mode="RGB", source="upload", label="Upload Image", optional=False)
outputs = gr.outputs.Image(type="pil", label="Output Image")

Custom_description="Custom Training Performed on colab 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"

Footer = (
    "MOdel train on our custome dataset")

examples1=[["Image1.jpeg"],["Image2.jpeg"],["Image3.jpeg"],["Image4.jpeg"],["Image5.jpeg"],["Image6.jpeg"],["horses.jpeg"],["horses.jpeg"]]

Top_Title="<center>Yolov7 🚀 Custom Trained style='text-decoration: underline' target='_blank'></center></a>Face with mask and face without mask Detection"
css = ".output-image, .input-image {height: 50rem !important; width: 100% !important;}"
css = ".image-preview {height: auto !important;}"

gr.Interface(
    fn=object_detection,
    inputs=image,
    outputs=outputs,
    title=Top_Title,
    description=Custom_description,
    article=Footer,
    examples=[["mask-person-2.jpg"], ["mask-person-2.jpg"]]).launch()