Spaces:
Sleeping
Sleeping
Gregg detector initial commit
Browse files- .gitignore +6 -0
- app.py +75 -0
- requirements.txt +0 -0
- saved_model/fingerprint.pb +3 -0
- saved_model/saved_model.pb +3 -0
- saved_model/variables/variables.data-00000-of-00001 +3 -0
- saved_model/variables/variables.index +3 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
flagged/
|
2 |
+
*.pt
|
3 |
+
*.png
|
4 |
+
*.jpg
|
5 |
+
*.mkv
|
6 |
+
gradio_cached_examples/
|
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import requests
|
4 |
+
import os
|
5 |
+
import tensorflow as tf
|
6 |
+
import numpy as np
|
7 |
+
|
8 |
+
file_urls = [
|
9 |
+
'https://drive.google.com/file/d/1dxNKawyagazR9TbxT6Fbla0opLqkROFG/view?usp=sharing',
|
10 |
+
'https://drive.google.com/file/d/109cc23-4HEyH9hFwenJjY7ZEVXj1-ZjW/view?usp=sharing',
|
11 |
+
'https://drive.google.com/file/d/1GLdsfug6n1tohqSAPmIzvCWZZSYIaHXj/view?usp=sharing'
|
12 |
+
]
|
13 |
+
|
14 |
+
def download_file(url, save_name):
|
15 |
+
if not os.path.exists(save_name):
|
16 |
+
file = requests.get(url)
|
17 |
+
open(save_name, 'wb').write(file.content)
|
18 |
+
|
19 |
+
for i, url in enumerate(file_urls):
|
20 |
+
if 'mp4' in file_urls[i]:
|
21 |
+
download_file(
|
22 |
+
file_urls[i],
|
23 |
+
f"video.mp4"
|
24 |
+
)
|
25 |
+
else:
|
26 |
+
download_file(
|
27 |
+
file_urls[i],
|
28 |
+
f"image_{i}.jpg"
|
29 |
+
)
|
30 |
+
|
31 |
+
# Load the TensorFlow model
|
32 |
+
model_path = 'path/to/your/tensorflow_model.pb' # Replace with your TensorFlow model path
|
33 |
+
model = tf.saved_model.load(model_path)
|
34 |
+
|
35 |
+
# Placeholder values for input dimensions
|
36 |
+
input_width = 640 # Replace with the actual input width of your model
|
37 |
+
input_height = 640 # Replace with the actual input height of your model
|
38 |
+
|
39 |
+
def predict_with_tf_model(image):
|
40 |
+
# Preprocess the image
|
41 |
+
image = cv2.resize(image, (input_width, input_height))
|
42 |
+
image = np.expand_dims(image, axis=0)
|
43 |
+
image = image / 255.0
|
44 |
+
|
45 |
+
# Run inference
|
46 |
+
output = model(image)
|
47 |
+
|
48 |
+
# Post-process the output if needed
|
49 |
+
|
50 |
+
return output
|
51 |
+
|
52 |
+
def show_preds_image(image_path):
|
53 |
+
image = cv2.imread(image_path)
|
54 |
+
|
55 |
+
# Perform inference using the TensorFlow model
|
56 |
+
output = predict_with_tf_model(image)
|
57 |
+
|
58 |
+
# Post-process the output and draw on the image if needed
|
59 |
+
|
60 |
+
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
61 |
+
|
62 |
+
inputs_image = [
|
63 |
+
gr.Image(type="file", label="Input Image"),
|
64 |
+
]
|
65 |
+
outputs_image = [
|
66 |
+
gr.Image(type="numpy", label="Output Image"),
|
67 |
+
]
|
68 |
+
interface_image = gr.Interface(
|
69 |
+
fn=show_preds_image,
|
70 |
+
inputs=inputs_image,
|
71 |
+
outputs=outputs_image,
|
72 |
+
title="Gregg Detector",
|
73 |
+
)
|
74 |
+
|
75 |
+
interface_image.launch()
|
requirements.txt
ADDED
File without changes
|
saved_model/fingerprint.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3e44411747571cc9e802c83b9a346200a4fd91495d8432a75cbe68cf2f4750e9
|
3 |
+
size 55
|
saved_model/saved_model.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b8c85d80cd2602b0c27be795c41ddb6a8e93b80eae288d350cf9642872619cf2
|
3 |
+
size 220153691
|
saved_model/variables/variables.data-00000-of-00001
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6ea6444d1d135200d03e4deb393a0a2a61a93e63dc4cef58693069013aed24e9
|
3 |
+
size 293721015
|
saved_model/variables/variables.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e9532ad97d8e1cfb948193803323400d8cd61fbe383b7323b8e5dfed7143f541
|
3 |
+
size 52997
|