infinitylogesh commited on
Commit
85ad04b
·
verified ·
1 Parent(s): 8c212c9

GUI-Decisions Space

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -20,6 +20,13 @@ BASE = os.environ.get("BASE", "google/gemma-4-31B-it")
20
  ADAPTER = os.environ.get("ADAPTER", "infinitylogesh/GUI-Decisions-31B-LoRA")
21
  SLOT, VANILLA = (37, 99, 235), (234, 88, 12) # blue: slot reads; orange: the base model writing JSON
22
  MAX_PX = 3840 * 2160
 
 
 
 
 
 
 
23
 
24
  m = LocalSlotModel.from_pretrained(BASE, adapter=ADAPTER, processor=ADAPTER, device_map="cpu")
25
  m.model.to("cuda")
@@ -93,7 +100,7 @@ def decide(image, instruction, previous, compare):
93
 
94
  md = (f"### Slots: `{describe(a, d, text)}`\n\n"
95
  f"One forward pass: **{ms:.0f} ms** on this GPU (bf16, transformers"
96
- + (", plus the base model writing the text" if text is not None else "") + ").")
97
  if compare:
98
  va, vpt, vargs, vtext, raw, vms = m.vanilla_decide(im, instruction, user_prev)
99
  if vpt is not None:
@@ -123,7 +130,7 @@ def box(image, description):
123
  w = unwarp(float(np.argmax(probs(lp["w"])) + 0.5) / m.arm.bins, "log")
124
  md = (f"### Box: `[{', '.join(f'{v:.3f}' for v in b)}]`\n\n"
125
  f"Centre and log-scaled size, four slots read in one forward pass: **{ms:.0f} ms** on this GPU. "
126
- f"The heatmap is the centre's x × y distribution (most likely width {w:.1%} of the image).")
127
  return out.convert("RGB"), md
128
 
129
 
 
20
  ADAPTER = os.environ.get("ADAPTER", "infinitylogesh/GUI-Decisions-31B-LoRA")
21
  SLOT, VANILLA = (37, 99, 235), (234, 88, 12) # blue: slot reads; orange: the base model writing JSON
22
  MAX_PX = 3840 * 2160
23
+ WARM = set() # functions that have run once in this process: the first call includes CUDA warm-up
24
+
25
+
26
+ def warm_note(name):
27
+ first = name not in WARM
28
+ WARM.add(name)
29
+ return " The first request after a restart includes GPU warm-up; run it again for a warm time." if first else ""
30
 
31
  m = LocalSlotModel.from_pretrained(BASE, adapter=ADAPTER, processor=ADAPTER, device_map="cpu")
32
  m.model.to("cuda")
 
100
 
101
  md = (f"### Slots: `{describe(a, d, text)}`\n\n"
102
  f"One forward pass: **{ms:.0f} ms** on this GPU (bf16, transformers"
103
+ + (", plus the base model writing the text" if text is not None else "") + ")." + warm_note("decide"))
104
  if compare:
105
  va, vpt, vargs, vtext, raw, vms = m.vanilla_decide(im, instruction, user_prev)
106
  if vpt is not None:
 
130
  w = unwarp(float(np.argmax(probs(lp["w"])) + 0.5) / m.arm.bins, "log")
131
  md = (f"### Box: `[{', '.join(f'{v:.3f}' for v in b)}]`\n\n"
132
  f"Centre and log-scaled size, four slots read in one forward pass: **{ms:.0f} ms** on this GPU. "
133
+ f"The heatmap is the centre's x × y distribution (most likely width {w:.1%} of the image)." + warm_note("box"))
134
  return out.convert("RGB"), md
135
 
136