Spaces:
Runtime error
Runtime error
Alex Cabrera
commited on
Commit
β’
c20a7cd
1
Parent(s):
fe4e75b
update
Browse files- .zeno_cache/EMBEDDINGIMAGENET1K_V1.pickle +2 -2
- .zeno_cache/EMBEDDINGIMAGENET1K_V2.pickle +2 -2
- .zeno_cache/EMBEDDINGresnet+clip.pickle +0 -3
- .zeno_cache/OUTPUTIMAGENET1K_V1.pickle +2 -2
- .zeno_cache/OUTPUTIMAGENET1K_V2.pickle +2 -2
- .zeno_cache/POSTDISTILLcorrectIMAGENET1K_V1.pickle +0 -3
- .zeno_cache/POSTDISTILLcorrectIMAGENET1K_V2.pickle +0 -3
- .zeno_cache/{PREDISTILLblue_border_count.pickle β POSTDISTILLincorrectIMAGENET1K_V1.pickle} +2 -2
- .zeno_cache/{OUTPUTresnet+clip.pickle β POSTDISTILLincorrectIMAGENET1K_V2.pickle} +2 -2
- .zeno_cache/POSTDISTILLoutput_labelIMAGENET1K_V1.pickle +2 -2
- .zeno_cache/POSTDISTILLoutput_labelIMAGENET1K_V2.pickle +2 -2
- .zeno_cache/PREDISTILLborder_brightness.pickle +2 -2
- .zeno_cache/PREDISTILLbrightness.pickle +2 -2
- .zeno_cache/PREDISTILLred_count.pickle +0 -3
- .zeno_cache/folders.pickle +2 -2
- .zeno_cache/reports.pickle +2 -2
- .zeno_cache/slices.pickle +2 -2
- __pycache__/brightness.cpython-38.pyc +0 -0
- __pycache__/color.cpython-38.pyc +0 -0
- __pycache__/inference.cpython-38.pyc +0 -0
- __pycache__/metrics.cpython-38.pyc +0 -0
- color.py +0 -51
- config.toml +6 -3
- functions/__pycache__/brightness.cpython-38.pyc +0 -0
- {__pycache__ β functions/__pycache__}/loading.cpython-38.pyc +0 -0
- functions/__pycache__/metrics.cpython-38.pyc +0 -0
- brightness.py β functions/brightness.py +3 -2
- loading.py β functions/loading.py +2 -1
- functions/metrics.py +40 -0
- inference.py +0 -11
- metrics.py +0 -31
- requirements.txt +1 -1
.zeno_cache/EMBEDDINGIMAGENET1K_V1.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:96927109662aeedd9bc8f360bac3f554f4a09f3cd36de6d4c0fcc40a6ad9a351
|
3 |
+
size 6408501
|
.zeno_cache/EMBEDDINGIMAGENET1K_V2.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:81ebfff49566d4a53d83837a1e77033fecd5842db1f2c5f387c49c75401ab715
|
3 |
+
size 32459336
|
.zeno_cache/EMBEDDINGresnet+clip.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:f9d66f744de0b18b789b09e80a3114a532e237d70ae5a7783fd16e78c60172b0
|
3 |
-
size 1762825
|
|
|
|
|
|
|
|
.zeno_cache/OUTPUTIMAGENET1K_V1.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85b1ac79bc95a1ad26887539d789f9d023f9494fd0f627d91104c6fda4678268
|
3 |
+
size 186098
|
.zeno_cache/OUTPUTIMAGENET1K_V2.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:61ab659b672b662ef69f6f785e6012da413e08df68196c8d0747a0736851a884
|
3 |
+
size 185058
|
.zeno_cache/POSTDISTILLcorrectIMAGENET1K_V1.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:56cc4b148a91afe661b1b64b71546d4f929b108b4dd3675cebd6ecde9b540b33
|
3 |
-
size 167854
|
|
|
|
|
|
|
|
.zeno_cache/POSTDISTILLcorrectIMAGENET1K_V2.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:b58173c01dada0075defbbfa081b673693168fd560c2d9bbb8034022bea06f9f
|
3 |
-
size 167854
|
|
|
|
|
|
|
|
.zeno_cache/{PREDISTILLblue_border_count.pickle β POSTDISTILLincorrectIMAGENET1K_V1.pickle}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5fa0582cfdaca3982c08905933bdeacdbe56f0015b2c8bb5246ac78edf4a31f9
|
3 |
+
size 167814
|
.zeno_cache/{OUTPUTresnet+clip.pickle β POSTDISTILLincorrectIMAGENET1K_V2.pickle}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee16c9cd7b0bc39b53fd7fabb4a2222a031c574d0266fc73179b24cdea7e4bc7
|
3 |
+
size 167814
|
.zeno_cache/POSTDISTILLoutput_labelIMAGENET1K_V1.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3e7c313894d5f63d5e2f7778cd0295fd09ce7bc902965e0674ce2a7744323d2d
|
3 |
+
size 186081
|
.zeno_cache/POSTDISTILLoutput_labelIMAGENET1K_V2.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cbdb8582997ccb184cb0b7e412874154ded3f0368d9b7224d449b194faa0f302
|
3 |
+
size 185075
|
.zeno_cache/PREDISTILLborder_brightness.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ea251ea165919ebdbc1a8e6c7957d4b93fabc9a99167daa095b538ecebf46489
|
3 |
+
size 199217
|
.zeno_cache/PREDISTILLbrightness.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1e1e21f96594b4d4dca3d641cc8b691326528f57918a161fadf9b0898efffd02
|
3 |
+
size 199210
|
.zeno_cache/PREDISTILLred_count.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:e6a63cb93322c957969f428adf797b5fa2a73a03ecd4409102e8c1430d7e5cdd
|
3 |
-
size 172023
|
|
|
|
|
|
|
|
.zeno_cache/folders.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e42dc27b16c2eea3b301e17de2ec138708fda5ecb1816365e3526c3d5ca58cd2
|
3 |
+
size 42
|
.zeno_cache/reports.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:139a92c5150957a37e5ef2a4a5aa44ed8c6da6a133e98a3c738ae66e0084b844
|
3 |
+
size 24190
|
.zeno_cache/slices.pickle
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:502150288ebdafdbc027ad2ac1e336e015d9368198debd7fc6d8674157d5fb75
|
3 |
+
size 8496
|
__pycache__/brightness.cpython-38.pyc
DELETED
Binary file (1.69 kB)
|
|
__pycache__/color.cpython-38.pyc
DELETED
Binary file (2.03 kB)
|
|
__pycache__/inference.cpython-38.pyc
DELETED
Binary file (504 Bytes)
|
|
__pycache__/metrics.cpython-38.pyc
DELETED
Binary file (1.13 kB)
|
|
color.py
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
import colorsys
|
2 |
-
import os
|
3 |
-
|
4 |
-
import numpy as np
|
5 |
-
from PIL import Image
|
6 |
-
from zeno import distill
|
7 |
-
from zeno.api import ZenoOptions
|
8 |
-
|
9 |
-
|
10 |
-
def red_pixels(im):
|
11 |
-
arr = np.array(im)
|
12 |
-
count_red = 0
|
13 |
-
for x in range(arr.shape[0]):
|
14 |
-
for y in range(arr.shape[1]):
|
15 |
-
if arr[x, y, 0] > 180 and arr[x, y, 1] < 70 and arr[x, y, 2] < 70:
|
16 |
-
count_red += 1
|
17 |
-
return count_red
|
18 |
-
|
19 |
-
|
20 |
-
def blue_border_pixels(im):
|
21 |
-
arr = np.array(im)
|
22 |
-
count_blue = 0
|
23 |
-
for x in range(arr.shape[0]):
|
24 |
-
for y in range(10):
|
25 |
-
hsv = colorsys.rgb_to_hsv(arr[x, y, 0], arr[x, y, 1], arr[x, y, 2])
|
26 |
-
if hsv[0] > 0.51 and hsv[0] < 0.72:
|
27 |
-
count_blue += 1
|
28 |
-
for x in range(arr.shape[0]):
|
29 |
-
for y in range(arr.shape[1] - 10, arr.shape[1]):
|
30 |
-
hsv = colorsys.rgb_to_hsv(arr[x, y, 0], arr[x, y, 1], arr[x, y, 2])
|
31 |
-
if hsv[0] > 0.51 and hsv[0] < 0.72:
|
32 |
-
count_blue += 1
|
33 |
-
return count_blue
|
34 |
-
|
35 |
-
|
36 |
-
@distill
|
37 |
-
def red_count(df, ops: ZenoOptions):
|
38 |
-
imgs = [
|
39 |
-
Image.open(os.path.join(ops.data_path, img)).convert("RGB")
|
40 |
-
for img in df[ops.data_column]
|
41 |
-
]
|
42 |
-
return [red_pixels(im) for im in imgs]
|
43 |
-
|
44 |
-
|
45 |
-
@distill
|
46 |
-
def blue_border_count(df, ops):
|
47 |
-
imgs = [
|
48 |
-
Image.open(os.path.join(ops.data_path, img)).convert("RGB")
|
49 |
-
for img in df[ops.data_column]
|
50 |
-
]
|
51 |
-
return [blue_border_pixels(im) for im in imgs]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.toml
CHANGED
@@ -1,11 +1,14 @@
|
|
1 |
-
functions = "./"
|
2 |
view = "image-classification"
|
3 |
metadata = "./imagenette_formatted.csv"
|
4 |
models = ["IMAGENET1K_V1", "IMAGENET1K_V2"]
|
5 |
data_path = "./imagenette/"
|
6 |
data_column = "id"
|
|
|
7 |
label_column = "label"
|
8 |
batch_size = 32
|
9 |
-
port = 7860
|
10 |
host = "0.0.0.0"
|
11 |
-
editable = false
|
|
|
|
|
|
1 |
+
functions = "./functions"
|
2 |
view = "image-classification"
|
3 |
metadata = "./imagenette_formatted.csv"
|
4 |
models = ["IMAGENET1K_V1", "IMAGENET1K_V2"]
|
5 |
data_path = "./imagenette/"
|
6 |
data_column = "id"
|
7 |
+
id_column = "id"
|
8 |
label_column = "label"
|
9 |
batch_size = 32
|
10 |
+
port = 7860
|
11 |
host = "0.0.0.0"
|
12 |
+
editable = false
|
13 |
+
# host = "localhost"
|
14 |
+
# editable = true
|
functions/__pycache__/brightness.cpython-38.pyc
ADDED
Binary file (1.8 kB). View file
|
|
{__pycache__ β functions/__pycache__}/loading.cpython-38.pyc
RENAMED
Binary files a/__pycache__/loading.cpython-38.pyc and b/functions/__pycache__/loading.cpython-38.pyc differ
|
|
functions/__pycache__/metrics.cpython-38.pyc
ADDED
Binary file (1.45 kB). View file
|
|
brightness.py β functions/brightness.py
RENAMED
@@ -2,6 +2,7 @@ import os
|
|
2 |
|
3 |
from PIL import Image
|
4 |
from zeno import distill
|
|
|
5 |
|
6 |
|
7 |
def get_brightness(im):
|
@@ -35,10 +36,10 @@ def get_border_brightness(im):
|
|
35 |
@distill
|
36 |
def brightness(df, ops):
|
37 |
imgs = [Image.open(os.path.join(ops.data_path, img)) for img in df[ops.data_column]]
|
38 |
-
return [get_brightness(im) for im in imgs]
|
39 |
|
40 |
|
41 |
@distill
|
42 |
def border_brightness(df, ops):
|
43 |
imgs = [Image.open(os.path.join(ops.data_path, img)) for img in df[ops.data_column]]
|
44 |
-
return [get_border_brightness(im) for im in imgs]
|
|
|
2 |
|
3 |
from PIL import Image
|
4 |
from zeno import distill
|
5 |
+
from zeno.api import DistillReturn
|
6 |
|
7 |
|
8 |
def get_brightness(im):
|
|
|
36 |
@distill
|
37 |
def brightness(df, ops):
|
38 |
imgs = [Image.open(os.path.join(ops.data_path, img)) for img in df[ops.data_column]]
|
39 |
+
return DistillReturn(distill_output=[get_brightness(im) for im in imgs])
|
40 |
|
41 |
|
42 |
@distill
|
43 |
def border_brightness(df, ops):
|
44 |
imgs = [Image.open(os.path.join(ops.data_path, img)) for img in df[ops.data_column]]
|
45 |
+
return DistillReturn(distill_output=[get_border_brightness(im) for im in imgs])
|
loading.py β functions/loading.py
RENAMED
@@ -8,6 +8,7 @@ import torch
|
|
8 |
|
9 |
|
10 |
from zeno import model
|
|
|
11 |
|
12 |
DEVICE = "cpu"
|
13 |
|
@@ -77,7 +78,7 @@ def load_model(model_path):
|
|
77 |
batches_highest_confidence = outputs.argmax(dim=1)
|
78 |
preds = [simple_labels[i] for i in batches_highest_confidence]
|
79 |
|
80 |
-
return preds, embeddings
|
81 |
|
82 |
return pred
|
83 |
|
|
|
8 |
|
9 |
|
10 |
from zeno import model
|
11 |
+
from zeno.api import ModelReturn
|
12 |
|
13 |
DEVICE = "cpu"
|
14 |
|
|
|
78 |
batches_highest_confidence = outputs.argmax(dim=1)
|
79 |
preds = [simple_labels[i] for i in batches_highest_confidence]
|
80 |
|
81 |
+
return ModelReturn(model_output=preds, embedding=embeddings)
|
82 |
|
83 |
return pred
|
84 |
|
functions/metrics.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pandas import DataFrame
|
2 |
+
from sklearn.metrics import f1_score, recall_score
|
3 |
+
from zeno import ZenoOptions, MetricReturn, metric, distill, DistillReturn
|
4 |
+
|
5 |
+
|
6 |
+
@metric
|
7 |
+
def accuracy(df, ops: ZenoOptions):
|
8 |
+
if len(df) == 0:
|
9 |
+
return MetricReturn(metric=0)
|
10 |
+
return MetricReturn(
|
11 |
+
metric=100 * (df[ops.label_column] == df[ops.output_column]).sum() / len(df)
|
12 |
+
)
|
13 |
+
|
14 |
+
|
15 |
+
@metric
|
16 |
+
def recall(df, ops: ZenoOptions):
|
17 |
+
rec = recall_score(df[ops.label_column], df[ops.output_column], average="macro")
|
18 |
+
if type(rec) == float:
|
19 |
+
return MetricReturn(metric=100 * float(rec))
|
20 |
+
else:
|
21 |
+
return MetricReturn(metric=0)
|
22 |
+
|
23 |
+
|
24 |
+
@metric
|
25 |
+
def f1(df, ops: ZenoOptions):
|
26 |
+
f = f1_score(df[ops.label_column], df[ops.output_column], average="macro")
|
27 |
+
if type(f) == float:
|
28 |
+
return MetricReturn(metric=100 * f)
|
29 |
+
else:
|
30 |
+
return MetricReturn(metric=0)
|
31 |
+
|
32 |
+
|
33 |
+
@distill
|
34 |
+
def incorrect(df: DataFrame, ops: ZenoOptions):
|
35 |
+
return DistillReturn(distill_output=df[ops.label_column] != df[ops.output_column])
|
36 |
+
|
37 |
+
|
38 |
+
@distill
|
39 |
+
def output_label(df: DataFrame, ops: ZenoOptions):
|
40 |
+
return DistillReturn(distill_output=df[ops.output_column])
|
inference.py
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
from zeno import inference, ZenoOptions
|
2 |
-
import gradio as gr
|
3 |
-
|
4 |
-
|
5 |
-
@inference
|
6 |
-
def gradio_inference(ops: ZenoOptions):
|
7 |
-
return (
|
8 |
-
[gr.Image(type="filepath"), gr.Textbox(label="Label")],
|
9 |
-
gr.Text(label="Output"),
|
10 |
-
[ops.data_column, ops.label_column],
|
11 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
metrics.py
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
from sklearn.metrics import f1_score, recall_score
|
2 |
-
from zeno import ZenoOptions, distill, metric
|
3 |
-
|
4 |
-
|
5 |
-
@metric
|
6 |
-
def accuracy(df, ops: ZenoOptions):
|
7 |
-
if len(df) == 0:
|
8 |
-
return 0
|
9 |
-
return 100 * (df[ops.label_column] == df[ops.output_column]).sum() / len(df)
|
10 |
-
|
11 |
-
|
12 |
-
@metric
|
13 |
-
def recall(df, ops: ZenoOptions):
|
14 |
-
return 100 * recall_score(
|
15 |
-
df[ops.label_column], df[ops.output_column], average="macro"
|
16 |
-
)
|
17 |
-
|
18 |
-
|
19 |
-
@metric
|
20 |
-
def f1(df, ops: ZenoOptions):
|
21 |
-
return 100 * f1_score(df[ops.label_column], df[ops.output_column], average="macro")
|
22 |
-
|
23 |
-
|
24 |
-
@distill
|
25 |
-
def correct(df, ops: ZenoOptions):
|
26 |
-
return (df[ops.label_column] == df[ops.output_column]).tolist()
|
27 |
-
|
28 |
-
|
29 |
-
@distill
|
30 |
-
def output_label(df, ops: ZenoOptions):
|
31 |
-
return df[ops.output_column]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
zenoml>=0.
|
2 |
Pillow
|
3 |
numpy
|
4 |
torch
|
|
|
1 |
+
zenoml>=0.4.6
|
2 |
Pillow
|
3 |
numpy
|
4 |
torch
|