Guillaume1989 commited on
Commit
16bb651
·
1 Parent(s): 8e9f6f0

chore: update examples + res

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. app.py +11 -24
  3. examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġperson.png +0 -3
  4. examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġriding.png +0 -3
  5. examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġthe.png +0 -3
  6. examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmaps.json +0 -0
  7. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_a.png +3 -0
  8. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_bicycle.png +3 -0
  9. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_near.png +3 -0
  10. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_ocean.png +3 -0
  11. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_person.png +3 -0
  12. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_riding.png +3 -0
  13. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_the.png +3 -0
  14. examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmaps.json +3 -0
  15. examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/image.jpg +2 -2
  16. examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/img_url.txt +0 -0
  17. 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
  18. examples/{auto_a_person_riding_a_bicycle_near_20250702_150805 → auto_a_person_riding_a_bicycle_near_20250704_075555}/prompt.txt +0 -0
  19. examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġcomputing.png +0 -3
  20. examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġin.png +0 -3
  21. examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġjobs.png +0 -3
  22. examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġthe.png +0 -3
  23. examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġus.png +0 -3
  24. examples/auto_computing_jobs_in_the_us_20250702_150954/heatmaps.json +0 -0
  25. 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
  26. 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
  27. 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
  28. 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
  29. examples/auto_computing_jobs_in_the_us_20250704_075605/heatmap_us.png +3 -0
  30. examples/auto_computing_jobs_in_the_us_20250704_075605/heatmaps.json +3 -0
  31. examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/image.jpg +2 -2
  32. examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/img_url.txt +0 -0
  33. examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/preview_first_token.jpg +2 -2
  34. examples/{auto_computing_jobs_in_the_us_20250702_150954 → auto_computing_jobs_in_the_us_20250704_075605}/prompt.txt +0 -0
  35. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_bang.png +3 -0
  36. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_choices.png +3 -0
  37. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_graph.png +3 -0
  38. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_in.png +3 -0
  39. examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/heatmap_ladesh.png +2 -2
  40. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_of.png +3 -0
  41. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_profession.png +3 -0
  42. examples/auto_graph_of_profession_choices_in_20250704_080418/heatmaps.json +3 -0
  43. examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/image.jpg +2 -2
  44. examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/img_url.txt +0 -0
  45. examples/{auto_jobs_in_bangladesh_20250703_104007 → auto_graph_of_profession_choices_in_20250704_080418}/preview_first_token.jpg +2 -2
  46. examples/auto_graph_of_profession_choices_in_20250704_080418/prompt.txt +1 -0
  47. examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġbang.png +0 -3
  48. examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġin.png +0 -3
  49. examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġjobs.png +0 -3
  50. 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
- MIN_H = 512
32
-
33
- # ───────── component helper (Buttons vs Radio) ─────────
34
- if hasattr(gr, "Buttons"):
35
- ButtonsLike = gr.Buttons
36
- def buttons_update(toks):
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 = _ensure_h(Image.open(io.BytesIO(r.content)).convert("RGB"))
111
  except Exception as e:
112
  raise gr.Error(f"Image load failed: {e}")
113
 
114
- img_proc = img.copy(); MAPPER.process_image(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, img, maps)
120
 
121
  first_tok = toks[0]
122
  info = f"**Prompt:** {prompt}\n\n**Image URL:** {img_url}"
123
  return (
124
- buttons_update(toks), maps, img,
125
- gr.update(value=overlay(first_tok, maps, img), visible=True),
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

  • SHA256: bba9ca886eb7d45dd4527fa066b8888023e2ff5341bd7b46b2088d2ff32bcbd9
  • Pointer size: 131 Bytes
  • Size of remote file: 128 kB
examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġriding.png DELETED

Git LFS Details

  • SHA256: 5dc309695cffc874057ede3036706e04eb1a4773596cf1dcdfff4eee6e27d581
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
examples/auto_a_person_riding_a_bicycle_near_20250702_150805/heatmap_ġthe.png DELETED

Git LFS Details

  • SHA256: 6b138d5d3e128e16d222587a8e62477e41794c49a9016a6c1193fa20119e56df
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
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

  • SHA256: 30ddd1b97c201e24c35e3af7bbe427c02bf303a5411592d33187e653122dc2e4
  • Pointer size: 132 Bytes
  • Size of remote file: 1.05 MB
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_bicycle.png ADDED

Git LFS Details

  • SHA256: a57ed52490fba40d7d38a80a04604427b2252eb84c916e81ddcac5b34cb751fb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.04 MB
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_near.png ADDED

Git LFS Details

  • SHA256: 746e3e410f19be9f1d419ad9cbc75ed11cd5eadec4dd1e49dd85bfa5c54b843f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.04 MB
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_ocean.png ADDED

Git LFS Details

  • SHA256: ca546e264f4a9fad3e6762610950d24e2d7340f4d8d773c9a21586c1ed152641
  • Pointer size: 132 Bytes
  • Size of remote file: 1.02 MB
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_person.png ADDED

Git LFS Details

  • SHA256: bac36af783af41ac83b0400d8debb5c6a063c9d99039bd09d637beaea42745ee
  • Pointer size: 132 Bytes
  • Size of remote file: 1.04 MB
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_riding.png ADDED

Git LFS Details

  • SHA256: a74f3199c1642976a651fab828c72367347fdccb5bb7c1fe5070ff0aa2d40579
  • Pointer size: 132 Bytes
  • Size of remote file: 1.04 MB
examples/auto_a_person_riding_a_bicycle_near_20250704_075555/heatmap_the.png ADDED

Git LFS Details

  • SHA256: 0dc3471bf13e98f9043e3105362fe25963c7ac4a8b1f8d18c9763e424339f2d1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.05 MB
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

  • SHA256: 131bd15e9c0d4539f65838ef95a725d51970f012527ca1466abbde091a78a24d
  • Pointer size: 130 Bytes
  • Size of remote file: 80.9 kB
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġin.png DELETED

Git LFS Details

  • SHA256: 1c09d391b698445d84a427f6866c104e773b9bedfc0300a6857fde9a071f4f84
  • Pointer size: 130 Bytes
  • Size of remote file: 85.9 kB
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġjobs.png DELETED

Git LFS Details

  • SHA256: 61b5f9a91e087f455b4624fe42beedd8800f9f736bc3ae29ce57760f4a16d745
  • Pointer size: 130 Bytes
  • Size of remote file: 87.9 kB
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġthe.png DELETED

Git LFS Details

  • SHA256: 2fcb4ac9f5be2976af0d0bb28ca583f6f6ac4411958da4a93560dbf9a51722c4
  • Pointer size: 130 Bytes
  • Size of remote file: 86.3 kB
examples/auto_computing_jobs_in_the_us_20250702_150954/heatmap_ġus.png DELETED

Git LFS Details

  • SHA256: 62cffc507bad2d71446915e345f3e321dfe53db51411de10e781fcf194fd9b1f
  • Pointer size: 130 Bytes
  • Size of remote file: 87 kB
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

  • SHA256: e14ef4f83c4578d77a3caff90a7a0c05775d292543319d0b468698c6aa3b3384
  • Pointer size: 131 Bytes
  • Size of remote file: 718 kB
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

  • SHA256: f4b31c94d1cf40bf7fa7df6720f4e4c59a99516a9257283ab4e36b2f3a976e65
  • Pointer size: 131 Bytes
  • Size of remote file: 597 kB
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_choices.png ADDED

Git LFS Details

  • SHA256: 4e9774f70eea20444f5144f1d4a19e92d575216d3fdf86bebb1a9564e1a82b36
  • Pointer size: 131 Bytes
  • Size of remote file: 551 kB
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_graph.png ADDED

Git LFS Details

  • SHA256: 1d0381581634f49230af2faebcb84577f62512c77ca0b13ff9b2842cffd10e11
  • Pointer size: 131 Bytes
  • Size of remote file: 531 kB
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_in.png ADDED

Git LFS Details

  • SHA256: 3203997d5b961e72e4056e680b04fa813af042ff0b015614d7f5622423f0873d
  • Pointer size: 131 Bytes
  • Size of remote file: 627 kB
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

  • SHA256: 506a876f3244983d60b08c54c46536037f6c7ab08af3e4bb9fa416cda93cb9ab
  • Pointer size: 131 Bytes
  • Size of remote file: 497 kB
examples/auto_graph_of_profession_choices_in_20250704_080418/heatmap_profession.png ADDED

Git LFS Details

  • SHA256: 8dd394f9a1ca470d17859c015a76fa24d65ddf67e382e6cece68ceda9a0515c3
  • Pointer size: 131 Bytes
  • Size of remote file: 559 kB
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

  • SHA256: 5edcc153fef6eebcd1d48c7986e65aa7a171e31f77c0291cdcd220786a852cd3
  • Pointer size: 130 Bytes
  • Size of remote file: 75.2 kB
examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġin.png DELETED

Git LFS Details

  • SHA256: 5a458bbe264bfa6c667480199479bc8f3612cd15e37dff2a0952b7c917cee985
  • Pointer size: 130 Bytes
  • Size of remote file: 79.5 kB
examples/auto_jobs_in_bangladesh_20250703_104007/heatmap_ġjobs.png DELETED

Git LFS Details

  • SHA256: 49790b318b5814c02e9f86bf9a34da917e97cfcaee41df807bea85f1d891f27a
  • Pointer size: 130 Bytes
  • Size of remote file: 73.8 kB
examples/auto_jobs_in_bangladesh_20250703_104007/heatmaps.json DELETED
The diff for this file is too large to render. See raw diff