Spaces:
Runtime error
Runtime error
eddydecena
commited on
Commit
•
9bfa5a4
1
Parent(s):
7747f33
Update app.py
Browse files
app.py
CHANGED
@@ -12,14 +12,23 @@ from src.config import IMAGE_SIZE
|
|
12 |
data_augmentation = get_data_augmentation()
|
13 |
cache_dir = os.path.join('hf_hub')
|
14 |
|
|
|
15 |
for f in ['checkpoint', 'checkpoint.data-00000-of-00001', 'checkpoint.index']:
|
16 |
-
print(f)
|
17 |
old_name = hf_hub_download(repo_id="eddydecena/cat-vs-dog", filename=f"tuner_model/cat-vs-dog/trial_0484d8d758a5ef7b91ca97d334ba7870/checkpoints/epoch_0/{f}", cache_dir=cache_dir)
|
18 |
temp_value = old_name.split('/')
|
19 |
temp_value.pop(-1)
|
20 |
path = '/'.join(temp_value)
|
21 |
os.rename(old_name, os.path.join(path, f))
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
latest = tf.train.latest_checkpoint(cache_dir)
|
24 |
hypermodel = MakeHyperModel(input_shape=IMAGE_SIZE + (3,), num_classes=2, data_augmentation=data_augmentation)
|
25 |
model = hypermodel.build(hp=HyperParameters())
|
@@ -39,10 +48,10 @@ iface = gr.Interface(
|
|
39 |
capture_session=True,
|
40 |
interpretation="default",
|
41 |
examples=[
|
42 |
-
["
|
43 |
-
["
|
44 |
-
["
|
45 |
-
["
|
46 |
])
|
47 |
|
48 |
if __name__ == "__main__":
|
|
|
12 |
data_augmentation = get_data_augmentation()
|
13 |
cache_dir = os.path.join('hf_hub')
|
14 |
|
15 |
+
# Download models
|
16 |
for f in ['checkpoint', 'checkpoint.data-00000-of-00001', 'checkpoint.index']:
|
|
|
17 |
old_name = hf_hub_download(repo_id="eddydecena/cat-vs-dog", filename=f"tuner_model/cat-vs-dog/trial_0484d8d758a5ef7b91ca97d334ba7870/checkpoints/epoch_0/{f}", cache_dir=cache_dir)
|
18 |
temp_value = old_name.split('/')
|
19 |
temp_value.pop(-1)
|
20 |
path = '/'.join(temp_value)
|
21 |
os.rename(old_name, os.path.join(path, f))
|
22 |
|
23 |
+
# Download examples images
|
24 |
+
examples_cache_dir = 'examples'
|
25 |
+
for image in ['cat1.jpg', 'cat2.jpg', 'dog1.jpeg', 'dog2.jpeg']:
|
26 |
+
old_name = hf_hub_download(repo_id="eddydecena/cat-vs-dog", filename=f"examples/{image}", cache_dir=examples_cache_dir)
|
27 |
+
temp_value = old_name.split('/')
|
28 |
+
temp_value.pop(-1)
|
29 |
+
path = '/'.join(temp_value)
|
30 |
+
os.rename(old_name, os.path.join(path, images))
|
31 |
+
|
32 |
latest = tf.train.latest_checkpoint(cache_dir)
|
33 |
hypermodel = MakeHyperModel(input_shape=IMAGE_SIZE + (3,), num_classes=2, data_augmentation=data_augmentation)
|
34 |
model = hypermodel.build(hp=HyperParameters())
|
|
|
48 |
capture_session=True,
|
49 |
interpretation="default",
|
50 |
examples=[
|
51 |
+
[f"{example_cache_dir}/cat1.jpg"],
|
52 |
+
[f"{example_cahce_dir}/cat2.jpg"],
|
53 |
+
[f"{example_cahce_dir}/dog1.jpeg"],
|
54 |
+
[f"{example_cahce_dir}/dog2.jpeg"]
|
55 |
])
|
56 |
|
57 |
if __name__ == "__main__":
|