keremberke commited on
Commit
5acef02
1 Parent(s): 3f2e58b

upload space files

Browse files
.gitattributes CHANGED
@@ -32,3 +32,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ test_images/ss.png filter=lfs diff=lfs merge=lfs -text
36
+ test_images/ss2.png filter=lfs diff=lfs merge=lfs -text
37
+ test_images/ss3.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Valorant Object Detection
3
- emoji:
4
- colorFrom: green
5
- colorTo: red
6
  sdk: gradio
7
  sdk_version: 3.15.0
8
  app_file: app.py
 
1
  ---
2
  title: Valorant Object Detection
3
+ emoji: 🎮
4
+ colorFrom: red
5
+ colorTo: gray
6
  sdk: gradio
7
  sdk_version: 3.15.0
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import os
3
+ import json
4
+ import gradio as gr
5
+ import yolov5
6
+ from PIL import Image
7
+ from huggingface_hub import hf_hub_download
8
+
9
+ app_title = "Valorant Object Detection"
10
+ models_ids = ['keremberke/yolov5n-valorant', 'keremberke/yolov5s-valorant', 'keremberke/yolov5m-valorant']
11
+ article = f"<p style='text-align: center'> <a href='https://huggingface.co/{models_ids[-1]}'>huggingface.co/{models_ids[-1]}</a> | <a href='https://huggingface.co/keremberke/valorant-object-detection'>huggingface.co/keremberke/valorant-object-detection</a> | <a href='https://github.com/keremberke/awesome-yolov5-models'>awesome-yolov5-models</a> </p>"
12
+
13
+ current_model_id = models_ids[-1]
14
+ model = yolov5.load(current_model_id)
15
+
16
+ if space_content/test_images:
17
+ image_filenames = os.listdir(space_content/test_images)
18
+ examples = [
19
+ [Path(space_content/test_images) / image_filename, 0.25, models_ids[-1]]
20
+ for image_filename in image_filenames
21
+ ]
22
+ else:
23
+ examples = None
24
+
25
+
26
+ def predict(image, threshold=0.25, model_id=None):
27
+ # update model if required
28
+ global current_model_id
29
+ global model
30
+ if model_id != current_model_id:
31
+ model = yolov5.load(model_id)
32
+ current_model_id = model_id
33
+
34
+ # get model input size
35
+ config_path = hf_hub_download(repo_id=model_id, filename="config.json")
36
+ with open(config_path, "r") as f:
37
+ config = json.load(f)
38
+ input_size = config["input_size"]
39
+
40
+ # perform inference
41
+ model.conf = threshold
42
+ results = model(image, size=input_size)
43
+ numpy_image = results.render()[0]
44
+ output_image = Image.fromarray(numpy_image)
45
+ return output_image
46
+
47
+
48
+ gr.Interface(
49
+ title=app_title,
50
+ description="Created by 'keremberke'",
51
+ article=article,
52
+ fn=predict,
53
+ inputs=[
54
+ gr.Image(type="pil"),
55
+ gr.Slider(maximum=1, step=0.01, value=0.25),
56
+ gr.Dropdown(models_ids, value=models_ids[-1]),
57
+ ],
58
+ outputs=gr.Image(type="pil"),
59
+ examples=examples,
60
+ cache_examples=True if examples else False,
61
+ ).launch(enable_queue=True)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+
2
+ yolov5==7.0.5
3
+ gradio==3.15.0
4
+ torch
5
+ huggingface-hub
test_images/ss.png ADDED

Git LFS Details

  • SHA256: a2ac8ddc172541efe95ce39f17e95a6458136f4720be265661a3dedb75501016
  • Pointer size: 132 Bytes
  • Size of remote file: 2.63 MB
test_images/ss2.png ADDED

Git LFS Details

  • SHA256: a17f9cbf4ad2592c216247cd852228e26e72f1a7db27347667b5c1b842fe3536
  • Pointer size: 132 Bytes
  • Size of remote file: 2.17 MB
test_images/ss3.png ADDED

Git LFS Details

  • SHA256: 5bda60b5dea808e461f7696d7c006f9d1e50214bee0042c984da0679e027bb62
  • Pointer size: 132 Bytes
  • Size of remote file: 2.04 MB
test_images/ss4.jpg ADDED
test_images/ss5.jpg ADDED
test_images/ss6.jpg ADDED