Commit
·
16bb651
1
Parent(s):
8e9f6f0
chore: update examples + res
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- app.py +11 -24
- examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġperson.png +0 -3
- examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġriding.png +0 -3
- examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġthe.png +0 -3
- examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmaps.json +0 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_a.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_bicycle.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_near.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_ocean.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_person.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_riding.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_the.png +3 -0
- examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmaps.json +3 -0
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/image.jpg +2 -2
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/img_url.txt +0 -0
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/preview_first_token.jpg +2 -2
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/prompt.txt +0 -0
- examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġcomputing.png +0 -3
- examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġin.png +0 -3
- examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġjobs.png +0 -3
- examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġthe.png +0 -3
- examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġus.png +0 -3
- examples/auto_computing_jobs_in_the_us_20250702_150954/heatmaps.json +0 -0
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġa.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_computing.png} +2 -2
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġbicycle.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_in.png} +2 -2
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġnear.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_jobs.png} +2 -2
- examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġocean.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_the.png} +2 -2
- examples/auto_computing_jobs_in_the_us_20250704_075605/heatmap_us.png +3 -0
- examples/auto_computing_jobs_in_the_us_20250704_075605/heatmaps.json +3 -0
- examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/image.jpg +2 -2
- examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/img_url.txt +0 -0
- examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/preview_first_token.jpg +2 -2
- examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/prompt.txt +0 -0
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_bang.png +3 -0
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_choices.png +3 -0
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_graph.png +3 -0
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_in.png +3 -0
- examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/heatmap_ladesh.png +2 -2
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_of.png +3 -0
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_profession.png +3 -0
- examples/auto_graph_of_profession_choices_in_20250704_080418/heatmaps.json +3 -0
- examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/image.jpg +2 -2
- examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/img_url.txt +0 -0
- examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/preview_first_token.jpg +2 -2
- examples/auto_graph_of_profession_choices_in_20250704_080418/prompt.txt +1 -0
- examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġbang.png +0 -3
- examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġin.png +0 -3
- examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġjobs.png +0 -3
- examples/auto_jobs_in_bangladesh_20250703_104007/heatmaps.json +0 -0
.gitattributes
CHANGED
@@ -35,3 +35,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
*.png filter=lfs diff=lfs merge=lfs -text
|
37 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
|
|
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
*.png filter=lfs diff=lfs merge=lfs -text
|
37 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.json filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -28,30 +28,17 @@ from PIL import Image
|
|
28 |
from similarity import JinaV4SimilarityMapper
|
29 |
|
30 |
EX_DIR = Path("examples"); EX_DIR.mkdir(exist_ok=True)
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
first = toks[0] if toks else None
|
38 |
-
return ButtonsLike.update(choices=toks, value=first, visible=True)
|
39 |
-
else:
|
40 |
-
ButtonsLike = gr.Radio
|
41 |
-
def buttons_update(toks):
|
42 |
-
first = toks[0] if toks else None
|
43 |
-
return gr.update(choices=toks, value=first, visible=True)
|
44 |
|
45 |
# ───────── util functions ─────────
|
46 |
def _slug(t: str, n: int = 60) -> str:
|
47 |
return re.sub(r"[^\w\-]+", "_", t.lower())[:n] or "x"
|
48 |
|
49 |
-
def _ensure_h(img: Image.Image, h: int = MIN_H) -> Image.Image:
|
50 |
-
if img.height >= h:
|
51 |
-
return img
|
52 |
-
sc = h / img.height
|
53 |
-
return img.resize((int(img.width * sc), h), Image.BICUBIC)
|
54 |
-
|
55 |
def overlay(tok: str, maps: Dict[str, str], base: Image.Image) -> Image.Image:
|
56 |
if tok not in maps:
|
57 |
return base
|
@@ -107,22 +94,22 @@ def run_mapper(prompt: str, img_url: str):
|
|
107 |
raise gr.Error("Please provide an image URL.")
|
108 |
try:
|
109 |
r = requests.get(img_url, stream=True, timeout=10); r.raise_for_status()
|
110 |
-
img =
|
111 |
except Exception as e:
|
112 |
raise gr.Error(f"Image load failed: {e}")
|
113 |
|
114 |
-
img_proc
|
115 |
toks, maps = MAPPER.get_token_similarity_maps(prompt, img_proc)
|
116 |
if not toks:
|
117 |
raise gr.Error("Mapper returned no tokens.")
|
118 |
|
119 |
-
save_run(prompt, img_url,
|
120 |
|
121 |
first_tok = toks[0]
|
122 |
info = f"**Prompt:** {prompt}\n\n**Image URL:** {img_url}"
|
123 |
return (
|
124 |
-
buttons_update(toks), maps,
|
125 |
-
gr.update(value=overlay(first_tok, maps,
|
126 |
gr.update(value=info, visible=True),
|
127 |
"", "")
|
128 |
|
|
|
28 |
from similarity import JinaV4SimilarityMapper
|
29 |
|
30 |
EX_DIR = Path("examples"); EX_DIR.mkdir(exist_ok=True)
|
31 |
+
|
32 |
+
|
33 |
+
ButtonsLike = gr.Radio
|
34 |
+
def buttons_update(toks):
|
35 |
+
first = toks[0] if toks else None
|
36 |
+
return gr.update(choices=toks, value=first, visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# ───────── util functions ─────────
|
39 |
def _slug(t: str, n: int = 60) -> str:
|
40 |
return re.sub(r"[^\w\-]+", "_", t.lower())[:n] or "x"
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
def overlay(tok: str, maps: Dict[str, str], base: Image.Image) -> Image.Image:
|
43 |
if tok not in maps:
|
44 |
return base
|
|
|
94 |
raise gr.Error("Please provide an image URL.")
|
95 |
try:
|
96 |
r = requests.get(img_url, stream=True, timeout=10); r.raise_for_status()
|
97 |
+
img = Image.open(io.BytesIO(r.content)).convert("RGB")
|
98 |
except Exception as e:
|
99 |
raise gr.Error(f"Image load failed: {e}")
|
100 |
|
101 |
+
img_proc, _, _ = MAPPER.process_image(img_url)
|
102 |
toks, maps = MAPPER.get_token_similarity_maps(prompt, img_proc)
|
103 |
if not toks:
|
104 |
raise gr.Error("Mapper returned no tokens.")
|
105 |
|
106 |
+
# save_run(prompt, img_url, img_proc, maps)
|
107 |
|
108 |
first_tok = toks[0]
|
109 |
info = f"**Prompt:** {prompt}\n\n**Image URL:** {img_url}"
|
110 |
return (
|
111 |
+
buttons_update(toks), maps, img_proc,
|
112 |
+
gr.update(value=overlay(first_tok, maps, img_proc), visible=True),
|
113 |
gr.update(value=info, visible=True),
|
114 |
"", "")
|
115 |
|
examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġperson.png
DELETED
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġriding.png
DELETED
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġthe.png
DELETED
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmaps.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_a.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_bicycle.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_near.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_ocean.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_person.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_riding.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_the.png
ADDED
![]() |
Git LFS Details
|
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmaps.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7ed7cbae18b2f385885dd3fd7a84827602d7409d093aa3bd97da14742c480b4
|
3 |
+
size 11106301
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/image.jpg
RENAMED
File without changes
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/img_url.txt
RENAMED
File without changes
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/preview_first_token.jpg
RENAMED
File without changes
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/prompt.txt
RENAMED
File without changes
|
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġcomputing.png
DELETED
Git LFS Details
|
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġin.png
DELETED
Git LFS Details
|
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġjobs.png
DELETED
Git LFS Details
|
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġthe.png
DELETED
Git LFS Details
|
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġus.png
DELETED
Git LFS Details
|
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmaps.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġa.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_computing.png}
RENAMED
File without changes
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġbicycle.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_in.png}
RENAMED
File without changes
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġnear.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_jobs.png}
RENAMED
File without changes
|
examples/{auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġocean.png → auto_computing_jobs_in_the_us_20250704_075605/heatmap_the.png}
RENAMED
File without changes
|
examples/auto_computing_jobs_in_the_us_20250704_075605/heatmap_us.png
ADDED
![]() |
Git LFS Details
|
examples/auto_computing_jobs_in_the_us_20250704_075605/heatmaps.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3959c1fdb6fc989c962079ac38a603ecf9df3ea9eae0542e42a2f7bb4513bcb
|
3 |
+
size 4753664
|
examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/image.jpg
RENAMED
File without changes
|
examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/img_url.txt
RENAMED
File without changes
|
examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/preview_first_token.jpg
RENAMED
File without changes
|
examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/prompt.txt
RENAMED
File without changes
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_bang.png
ADDED
![]() |
Git LFS Details
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_choices.png
ADDED
![]() |
Git LFS Details
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_graph.png
ADDED
![]() |
Git LFS Details
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_in.png
ADDED
![]() |
Git LFS Details
|
examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/heatmap_ladesh.png
RENAMED
File without changes
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_of.png
ADDED
![]() |
Git LFS Details
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_profession.png
ADDED
![]() |
Git LFS Details
|
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmaps.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0913968a9be3fa664aa410912a2b7ca20813a96822b39745e56ce48a0e0690eb
|
3 |
+
size 5152100
|
examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/image.jpg
RENAMED
File without changes
|
examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/img_url.txt
RENAMED
File without changes
|
examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/preview_first_token.jpg
RENAMED
File without changes
|
examples/auto_graph_of_profession_choices_in_20250704_080418/prompt.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Graph of profession choices in bangladesh
|
examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġbang.png
DELETED
Git LFS Details
|
examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġin.png
DELETED
Git LFS Details
|
examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġjobs.png
DELETED
Git LFS Details
|
examples/auto_jobs_in_bangladesh_20250703_104007/heatmaps.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|