Spaces:
Runtime error
Runtime error
Add result example files, note how to call the API
Browse files- app.py +51 -5
- examples/jabberwock.png +0 -0
- examples/jabberwock.txt +25 -0
- examples/jabberwock_card.png +0 -0
app.py
CHANGED
@@ -315,14 +315,60 @@ app_description = (
|
|
315 |
Enter a name, click Submit, and wait for about 4 minutes to see the result.
|
316 |
""").strip()
|
317 |
input_box = gr.Textbox(label="Enter a monster name", placeholder="Jabberwock")
|
318 |
-
output_monster_card = gr.Image(label="Monster Card", type='pil')
|
319 |
-
output_text_box = gr.Textbox(label="Monster Text")
|
320 |
-
output_monster_image = gr.Image(label="Monster Image", type='pil')
|
321 |
output_monster_html = gr.HTML(label="Monster HTML", visible=False, show_label=False)
|
322 |
x = gr.components.Textbox()
|
323 |
iface = gr.Interface(title="MonsterGen", theme="default", description=app_description, fn=run, inputs=[input_box],
|
324 |
outputs=[output_monster_card, output_text_box, output_monster_image, output_monster_html])
|
325 |
iface.launch()
|
326 |
-
# https://gradio.app/sharing_your_app/#api-page
|
327 |
-
# Looks like API page improvements are in progress: https://github.com/gradio-app/gradio/issues/1325
|
328 |
# TODO: Add examples
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
Enter a name, click Submit, and wait for about 4 minutes to see the result.
|
316 |
""").strip()
|
317 |
input_box = gr.Textbox(label="Enter a monster name", placeholder="Jabberwock")
|
318 |
+
output_monster_card = gr.Image(label="Monster Card", type='pil', value="examples/jabberwock_card.png")
|
319 |
+
output_text_box = gr.Textbox(label="Monster Text", value=pathlib.Path("examples/jabberwock.txt").read_text('utf-8'))
|
320 |
+
output_monster_image = gr.Image(label="Monster Image", type='pil', value="examples/jabberwock.png")
|
321 |
output_monster_html = gr.HTML(label="Monster HTML", visible=False, show_label=False)
|
322 |
x = gr.components.Textbox()
|
323 |
iface = gr.Interface(title="MonsterGen", theme="default", description=app_description, fn=run, inputs=[input_box],
|
324 |
outputs=[output_monster_card, output_text_box, output_monster_image, output_monster_html])
|
325 |
iface.launch()
|
|
|
|
|
326 |
# TODO: Add examples
|
327 |
+
# API works, assuming query takes no longer than 30 seconds (504 gateway timeout)
|
328 |
+
# Looks like API page improvements are in progress: https://github.com/gradio-app/gradio/issues/1325
|
329 |
+
# Example code below:
|
330 |
+
# import requests
|
331 |
+
# r = requests.post(url='https://hf.space/embed/gstaff/test_space/+/api/predict', json={"data": [""]},
|
332 |
+
# timeout=None)
|
333 |
+
# print(r.json())
|
334 |
+
|
335 |
+
# Looks like Huggingface uses the queue push api, then polls for status:
|
336 |
+
# fetch("https://hf.space/embed/gstaff/test_space/api/queue/push/", {
|
337 |
+
# "headers": {
|
338 |
+
# "accept": "*/*",
|
339 |
+
# "accept-language": "en-US,en;q=0.9",
|
340 |
+
# "content-type": "application/json",
|
341 |
+
# "sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
|
342 |
+
# "sec-ch-ua-mobile": "?0",
|
343 |
+
# "sec-ch-ua-platform": "\"Windows\"",
|
344 |
+
# "sec-fetch-dest": "empty",
|
345 |
+
# "sec-fetch-mode": "cors",
|
346 |
+
# "sec-fetch-site": "same-origin"
|
347 |
+
# },
|
348 |
+
# "referrer": "https://hf.space/embed/gstaff/test_space/+?__theme=light",
|
349 |
+
# "referrerPolicy": "strict-origin-when-cross-origin",
|
350 |
+
# "body": "{\"fn_index\":0,\"data\":[\"Jabberwock\"],\"action\":\"predict\",\"session_hash\":\"v9ehgfho3p\"}",
|
351 |
+
# "method": "POST",
|
352 |
+
# "mode": "cors",
|
353 |
+
# "credentials": "omit"
|
354 |
+
# });
|
355 |
+
|
356 |
+
# fetch("https://hf.space/embed/gstaff/test_space/api/queue/status/", {
|
357 |
+
# "headers": {
|
358 |
+
# "accept": "*/*",
|
359 |
+
# "accept-language": "en-US,en;q=0.9",
|
360 |
+
# "content-type": "application/json",
|
361 |
+
# "sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
|
362 |
+
# "sec-ch-ua-mobile": "?0",
|
363 |
+
# "sec-ch-ua-platform": "\"Windows\"",
|
364 |
+
# "sec-fetch-dest": "empty",
|
365 |
+
# "sec-fetch-mode": "cors",
|
366 |
+
# "sec-fetch-site": "same-origin"
|
367 |
+
# },
|
368 |
+
# "referrer": "https://hf.space/embed/gstaff/test_space/+?__theme=light",
|
369 |
+
# "referrerPolicy": "strict-origin-when-cross-origin",
|
370 |
+
# "body": "{\"hash\":\"09f5369a7a414169aa48948bad5fd93d\"}",
|
371 |
+
# "method": "POST",
|
372 |
+
# "mode": "cors",
|
373 |
+
# "credentials": "omit"
|
374 |
+
# });
|
examples/jabberwock.png
ADDED
examples/jabberwock.txt
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Name: Jabberwock
|
2 |
+
Type: Medium humanoid (human), neutral evil
|
3 |
+
Description: A Jabberwock is a creature of the Deep Sea.
|
4 |
+
|
5 |
+
Stats:
|
6 |
+
Armor Class: 15 (breastplate)
|
7 |
+
Hit Points: 22 (5d8 + 5)
|
8 |
+
Speed: 30 ft
|
9 |
+
STR: 8 (-1)
|
10 |
+
DEX: 14 (+2)
|
11 |
+
CON: 12 (+1)
|
12 |
+
INT: 2 (-4)
|
13 |
+
WIS: 10 (+0)
|
14 |
+
CHA: 4 (-3)
|
15 |
+
Skills: Perception +3
|
16 |
+
Senses: darkvision 60 ft., passive Perception 14
|
17 |
+
Languages: —
|
18 |
+
Challenge: 1/4 (50 XP)
|
19 |
+
|
20 |
+
Passives:
|
21 |
+
Legendary Resistance (3/Day): If the Jabberwock fails a saving throw, it can choose to succeed instead
|
22 |
+
|
23 |
+
Actions:
|
24 |
+
Bite: Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 3) piercing damage.
|
25 |
+
Claws (Recharge 5-6): Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d10 + 3) slashing damage.
|
examples/jabberwock_card.png
ADDED