infiniteviolets commited on
Commit
8d482e7
·
verified ·
1 Parent(s): 18ab377

Remove the sign-in button: ZeroGPU quota follows the visitor's huggingface.co session, not app-level OAuth

Browse files
Files changed (3) hide show
  1. README.md +12 -8
  2. app.py +11 -25
  3. requirements.txt +4 -4
README.md CHANGED
@@ -9,8 +9,6 @@ app_file: app.py
9
  pinned: false
10
  license: mit
11
  short_description: Hide a short message inside LLM-generated cover text.
12
- hf_oauth: true
13
- hf_oauth_expiration_minutes: 480
14
  ---
15
 
16
  # Garfield-Naruto Encoder
@@ -27,17 +25,23 @@ runs entirely in the Space process and costs no GPU quota.
27
  This Space runs on **ZeroGPU**, where GPU time is charged to **the visitor's own
28
  account**, not to whoever published the Space. Quota is per user, per day.
29
 
30
- Sign in with the button on the Encode tab. Signing in matters:
31
-
32
  | | daily ZeroGPU quota |
33
  |---|---|
34
- | not signed in | ~2 minutes (tracked by IP) |
35
  | free account | ~5 minutes |
36
  | PRO / Team / Enterprise | 40+ minutes, and pay-as-you-go credits past that |
37
 
38
- Without signing in you fall back to the anonymous IP-based pool, which is small
39
- and shared. PRO users who exhaust their daily quota continue against their own
40
- pre-paid credits.
 
 
 
 
 
 
 
 
41
 
42
  ## Warning
43
 
 
9
  pinned: false
10
  license: mit
11
  short_description: Hide a short message inside LLM-generated cover text.
 
 
12
  ---
13
 
14
  # Garfield-Naruto Encoder
 
25
  This Space runs on **ZeroGPU**, where GPU time is charged to **the visitor's own
26
  account**, not to whoever published the Space. Quota is per user, per day.
27
 
 
 
28
  | | daily ZeroGPU quota |
29
  |---|---|
30
+ | not identified | ~2 minutes, tracked by IP and shared |
31
  | free account | ~5 minutes |
32
  | PRO / Team / Enterprise | 40+ minutes, and pay-as-you-go credits past that |
33
 
34
+ **There is no sign-in button, and you do not need one.** ZeroGPU identifies you
35
+ from the `x-ip-token` header that the Hugging Face proxy injects using your
36
+ huggingface.co session, so simply opening this Space in a browser where you are
37
+ signed in is what puts the time on your own account. An app-level OAuth button
38
+ (`gr.LoginButton` / `hf_oauth`) is a separate mechanism that tells the *app* who
39
+ you are without changing your quota, so one here would only be misleading.
40
+
41
+ Two situations fall back to the shared IP pool: not being signed in to
42
+ huggingface.co, and running this Space **embedded in a frame on another site** —
43
+ browsers restrict cookies in cross-site frames, so the proxy cannot see your
44
+ session. Open the Space directly to avoid both.
45
 
46
  ## Warning
47
 
app.py CHANGED
@@ -1,10 +1,14 @@
1
  """Garfield-Naruto encoder as a ZeroGPU Space.
2
 
3
  ZeroGPU bills GPU time to the *visitor's* account rather than to whoever
4
- published the Space, and quota is per user per day. Signing in matters: an
5
- anonymous visitor falls back to a small IP-tracked pool, while a signed-in PRO
6
- user gets their own large quota and can spill into their own pre-paid credits.
7
- That is what `hf_oauth: true` in README.md and the login button below are for.
 
 
 
 
8
 
9
  Encoding needs the model, so it runs inside @spaces.GPU. Decoding needs only the
10
  text and the key, so it stays outside and costs no quota at all.
@@ -36,10 +40,6 @@ MAX_MESSAGE_CHARS = int(os.environ.get("STEGO_MAX_CHARS", "160"))
36
  # sentence_encode's default rather than surfaced as a control.
37
  TEMPERATURE = float(os.environ.get("STEGO_TEMPERATURE", "0.9"))
38
 
39
- # gradio mocks the OAuth routes off-Space and then refuses to build unless the
40
- # local machine is logged in to HF, so the login button is only mounted when
41
- # actually running in a Space. This keeps `python app.py` usable for local work.
42
- IN_SPACE = bool(os.environ.get("SPACE_ID"))
43
 
44
  # ZeroGPU wants the model on cuda at module level: a CUDA emulation layer is
45
  # active outside @spaces.GPU, and placements made at startup are far cheaper
@@ -162,14 +162,6 @@ def decode(text, key):
162
  return f"Could not decode: {exc}\n\n(Wrong key, or the cover text was edited.)"
163
 
164
 
165
- def whoami(profile: gr.OAuthProfile | None) -> str:
166
- if profile is None:
167
- return ("**Not signed in.** GPU time will come from the small anonymous "
168
- "pool shared by IP. Sign in to use your own quota.")
169
- return (f"Signed in as **{profile.username}** — GPU time is billed to your "
170
- f"own ZeroGPU quota, not to the Space owner.")
171
-
172
-
173
  CSS = """
174
  #gn-out, #gn-decode-out textarea { font-family: ui-monospace, Menlo, Consolas, monospace; }
175
  """
@@ -199,13 +191,6 @@ with gr.Blocks(title="Garfield-Naruto Encoder") as demo:
199
  precision=0)
200
  go = gr.Button("Begin Encoding", variant="primary")
201
 
202
- if IN_SPACE:
203
- gr.LoginButton()
204
- who = gr.Markdown()
205
- demo.load(whoami, inputs=None, outputs=who)
206
- else:
207
- gr.Markdown("_Sign-in button appears when running on a Space._")
208
-
209
  out = gr.Textbox(label="Output", elem_id="gn-out", lines=10,
210
  placeholder="Output will appear here…")
211
  note = gr.Markdown()
@@ -244,8 +229,9 @@ with gr.Blocks(title="Garfield-Naruto Encoder") as demo:
244
  gr.Markdown(
245
  f"Model: `{MODEL_ID}` · GPU time on ZeroGPU is charged to the "
246
  "**visitor**, per account per day — not to the account hosting this "
247
- "Space. Sign in on the Encode tab to use your own quota instead of "
248
- "the shared anonymous pool."
 
249
  )
250
 
251
  if __name__ == "__main__":
 
1
  """Garfield-Naruto encoder as a ZeroGPU Space.
2
 
3
  ZeroGPU bills GPU time to the *visitor's* account rather than to whoever
4
+ published the Space, and quota is per user per day.
5
+
6
+ There is deliberately no sign-in button. ZeroGPU identifies a visitor from the
7
+ `x-ip-token` header the Hugging Face proxy injects using their huggingface.co
8
+ session, so quota already follows whoever opens the Space. An app-level OAuth
9
+ button (`gr.LoginButton` / `hf_oauth`) is a different mechanism: it would tell
10
+ *this app* who the user is without changing their quota at all. Having one
11
+ implied otherwise, so it was removed.
12
 
13
  Encoding needs the model, so it runs inside @spaces.GPU. Decoding needs only the
14
  text and the key, so it stays outside and costs no quota at all.
 
40
  # sentence_encode's default rather than surfaced as a control.
41
  TEMPERATURE = float(os.environ.get("STEGO_TEMPERATURE", "0.9"))
42
 
 
 
 
 
43
 
44
  # ZeroGPU wants the model on cuda at module level: a CUDA emulation layer is
45
  # active outside @spaces.GPU, and placements made at startup are far cheaper
 
162
  return f"Could not decode: {exc}\n\n(Wrong key, or the cover text was edited.)"
163
 
164
 
 
 
 
 
 
 
 
 
165
  CSS = """
166
  #gn-out, #gn-decode-out textarea { font-family: ui-monospace, Menlo, Consolas, monospace; }
167
  """
 
191
  precision=0)
192
  go = gr.Button("Begin Encoding", variant="primary")
193
 
 
 
 
 
 
 
 
194
  out = gr.Textbox(label="Output", elem_id="gn-out", lines=10,
195
  placeholder="Output will appear here…")
196
  note = gr.Markdown()
 
229
  gr.Markdown(
230
  f"Model: `{MODEL_ID}` · GPU time on ZeroGPU is charged to the "
231
  "**visitor**, per account per day — not to the account hosting this "
232
+ "Space. You are identified by your huggingface.co session, so open "
233
+ "this Space in a browser where you are signed in to use your own "
234
+ "quota rather than the pool shared by IP address."
235
  )
236
 
237
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -1,8 +1,8 @@
1
  # ZeroGPU supplies torch; pinning torch here can conflict with the runtime image.
2
- # gradio[oauth] is required for gr.LoginButton — sdk_version alone does NOT pull
3
- # in the OAuth extras, and the Space fails at import without it. Pinned to match
4
- # sdk_version in README.md so the extras cannot drag in a different gradio.
5
- gradio[oauth]==6.27.0
6
  transformers>=4.45
7
  accelerate
8
  numpy
 
1
  # ZeroGPU supplies torch; pinning torch here can conflict with the runtime image.
2
+ # No OAuth extras: the Space has no sign-in button, because ZeroGPU attributes
3
+ # quota from the visitor's huggingface.co session, not from app-level OAuth.
4
+ # Pinned to match sdk_version in README.md.
5
+ gradio==6.27.0
6
  transformers>=4.45
7
  accelerate
8
  numpy