Spaces:
Runtime error
Runtime error
Intial Commit
Browse files- .gitignore +3 -0
- app.py +42 -0
- lp1.jpg +0 -0
- lp2.jpg +0 -0
- nlp1.jpg +0 -0
- nlp2.jpg +0 -0
- requirements.txt +51 -0
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flagged/
|
| 2 |
+
*.pt
|
| 3 |
+
gradio_cached_examples/
|
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
|
| 7 |
+
# Model
|
| 8 |
+
# model = torch.hub.load("ultralytics/yolov5", "yolov5s") # or yolov5n - yolov5x6, custom
|
| 9 |
+
path = "obj.pt"
|
| 10 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path=path)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def yolo(im, size=640):
|
| 14 |
+
|
| 15 |
+
g = (size / max(im.size)) # gain
|
| 16 |
+
|
| 17 |
+
im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
|
| 18 |
+
|
| 19 |
+
results = model(im) # inference
|
| 20 |
+
|
| 21 |
+
# results.render() # updates results.imgs with boxes and labels
|
| 22 |
+
|
| 23 |
+
# return Image.fromarray(results.imgs[0])
|
| 24 |
+
|
| 25 |
+
# Retrieve the annotated image from the results (modify this based on your model's output structure)
|
| 26 |
+
annotated_image = results.render()[0]
|
| 27 |
+
|
| 28 |
+
# Return the annotated image
|
| 29 |
+
return Image.fromarray(annotated_image)
|
| 30 |
+
|
| 31 |
+
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
| 32 |
+
outputs = gr.outputs.Image(type="filepath", label="Output Image")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
title = "YOLOv5"
|
| 36 |
+
description = "YOLOv5 Gradio demo for object detection. Upload an image or click an example image to use."
|
| 37 |
+
|
| 38 |
+
article = "YOLOv5 Leprosy AI Demo"
|
| 39 |
+
|
| 40 |
+
examples = [["lp1.jpg"],["lp2.jpg"],["nlp1.jpg"],["nlp2.jpg"]]
|
| 41 |
+
gr.Interface(yolo, inputs, outputs, title=title, description=description, article=article, examples=examples, analytics_enabled=False).launch(
|
| 42 |
+
debug=True)
|
lp1.jpg
ADDED
|
lp2.jpg
ADDED
|
nlp1.jpg
ADDED
|
nlp2.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# YOLOv5 requirements
|
| 2 |
+
# Usage: pip install -r requirements.txt
|
| 3 |
+
|
| 4 |
+
# Base ------------------------------------------------------------------------
|
| 5 |
+
gitpython>=3.1.30
|
| 6 |
+
matplotlib>=3.3
|
| 7 |
+
numpy>=1.22.2
|
| 8 |
+
opencv-python>=4.1.1
|
| 9 |
+
Pillow>=7.1.2
|
| 10 |
+
psutil # system resources
|
| 11 |
+
PyYAML>=5.3.1
|
| 12 |
+
requests>=2.23.0
|
| 13 |
+
scipy>=1.4.1
|
| 14 |
+
thop>=0.1.1 # FLOPs computation
|
| 15 |
+
torch>=1.8.0 # see https://pytorch.org/get-started/locally (recommended)
|
| 16 |
+
torchvision>=0.9.0
|
| 17 |
+
tqdm>=4.64.0
|
| 18 |
+
ultralytics>=8.0.147
|
| 19 |
+
# protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012
|
| 20 |
+
|
| 21 |
+
# Logging ---------------------------------------------------------------------
|
| 22 |
+
# tensorboard>=2.4.1
|
| 23 |
+
# clearml>=1.2.0
|
| 24 |
+
# comet
|
| 25 |
+
|
| 26 |
+
# Plotting --------------------------------------------------------------------
|
| 27 |
+
pandas>=1.1.4
|
| 28 |
+
seaborn>=0.11.0
|
| 29 |
+
|
| 30 |
+
# Export ----------------------------------------------------------------------
|
| 31 |
+
# coremltools>=6.0 # CoreML export
|
| 32 |
+
# onnx>=1.10.0 # ONNX export
|
| 33 |
+
# onnx-simplifier>=0.4.1 # ONNX simplifier
|
| 34 |
+
# nvidia-pyindex # TensorRT export
|
| 35 |
+
# nvidia-tensorrt # TensorRT export
|
| 36 |
+
# scikit-learn<=1.1.2 # CoreML quantization
|
| 37 |
+
# tensorflow>=2.4.0 # TF exports (-cpu, -aarch64, -macos)
|
| 38 |
+
# tensorflowjs>=3.9.0 # TF.js export
|
| 39 |
+
# openvino-dev>=2023.0 # OpenVINO export
|
| 40 |
+
|
| 41 |
+
# Deploy ----------------------------------------------------------------------
|
| 42 |
+
setuptools>=65.5.1 # Snyk vulnerability fix
|
| 43 |
+
# tritonclient[all]~=2.24.0
|
| 44 |
+
|
| 45 |
+
# Extras ----------------------------------------------------------------------
|
| 46 |
+
# ipython # interactive notebook
|
| 47 |
+
# mss # screenshots
|
| 48 |
+
# albumentations>=1.0.3
|
| 49 |
+
# pycocotools>=2.0.6 # COCO mAP
|
| 50 |
+
|
| 51 |
+
gradio
|