Spaces:
Runtime error
Runtime error
fix demo
Browse files- README.md +1 -1
- app.py +24 -10
- requirements.txt +1 -1
- src/gradio_user_history/_user_history.py +0 -1
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
title: Gradio User History
|
3 |
sdk: gradio
|
4 |
-
sdk_version:
|
5 |
app_file: app.py
|
6 |
emoji: 🖼️
|
7 |
colorFrom: gray
|
|
|
1 |
---
|
2 |
title: Gradio User History
|
3 |
sdk: gradio
|
4 |
+
sdk_version: 4.27.0
|
5 |
app_file: app.py
|
6 |
emoji: 🖼️
|
7 |
colorFrom: gray
|
app.py
CHANGED
@@ -7,36 +7,50 @@ from pathlib import Path
|
|
7 |
import gradio as gr
|
8 |
import gradio_user_history as gr_user_history
|
9 |
from gradio_client import Client
|
10 |
-
|
11 |
from gradio_space_ci import enable_space_ci
|
12 |
|
|
|
13 |
enable_space_ci()
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
-
client = Client("
|
19 |
|
20 |
|
21 |
def generate(prompt: str, profile: gr.OAuthProfile | None) -> tuple[str, list[str]]:
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
metadata = {
|
25 |
"prompt": prompt,
|
26 |
"negative_prompt": "",
|
27 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as metadata_file:
|
30 |
json.dump(metadata, metadata_file)
|
31 |
|
32 |
-
with (pathlib.Path(out_dir) / "captions.json").open() as f:
|
33 |
-
paths = list(json.load(f).keys())
|
34 |
-
|
35 |
# Saving user history
|
36 |
-
|
37 |
-
gr_user_history.save_image(label=prompt, image=path, profile=profile, metadata=metadata)
|
38 |
|
39 |
-
return
|
40 |
|
41 |
|
42 |
with gr.Blocks(css="style.css") as demo:
|
|
|
7 |
import gradio as gr
|
8 |
import gradio_user_history as gr_user_history
|
9 |
from gradio_client import Client
|
|
|
10 |
from gradio_space_ci import enable_space_ci
|
11 |
|
12 |
+
|
13 |
enable_space_ci()
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
+
client = Client("multimodalart/stable-cascade")
|
19 |
|
20 |
|
21 |
def generate(prompt: str, profile: gr.OAuthProfile | None) -> tuple[str, list[str]]:
|
22 |
+
generated_img_path = client.predict(
|
23 |
+
prompt, # str in 'Prompt' Textbox component
|
24 |
+
"", # str in 'Negative prompt' Textbox component
|
25 |
+
0, # float (numeric value between 0 and 2147483647) in 'Seed' Slider component
|
26 |
+
1024, # float (numeric value between 1024 and 1536) in 'Width' Slider component
|
27 |
+
1024, # float (numeric value between 1024 and 1536) in 'Height' Slider component
|
28 |
+
20, # float (numeric value between 10 and 30) in 'Prior Inference Steps' Slider component
|
29 |
+
4, # float (numeric value between 0 and 20) in 'Prior Guidance Scale' Slider component
|
30 |
+
10, # float (numeric value between 4 and 12) in 'Decoder Inference Steps' Slider component
|
31 |
+
0, # float (numeric value between 0 and 0) in 'Decoder Guidance Scale' Slider component
|
32 |
+
1, # float (numeric value between 1 and 2) in 'Number of Images' Slider component
|
33 |
+
api_name="/run"
|
34 |
+
)
|
35 |
|
36 |
metadata = {
|
37 |
"prompt": prompt,
|
38 |
"negative_prompt": "",
|
39 |
+
"prior_inference_steps": 20,
|
40 |
+
"prior_guidance_scale": 4,
|
41 |
+
"decoder_inference_steps": 10,
|
42 |
+
"decoder_guidance_scale": 0,
|
43 |
+
"seed": 0,
|
44 |
+
"width": 1024,
|
45 |
+
"height": 1024,
|
46 |
}
|
47 |
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as metadata_file:
|
48 |
json.dump(metadata, metadata_file)
|
49 |
|
|
|
|
|
|
|
50 |
# Saving user history
|
51 |
+
gr_user_history.save_image(label=prompt, image=generated_img_path, profile=profile, metadata=metadata)
|
|
|
52 |
|
53 |
+
return [generated_img_path] # type: ignore
|
54 |
|
55 |
|
56 |
with gr.Blocks(css="style.css") as demo:
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
git+https://huggingface.co/spaces/Wauplin/gradio-user-history
|
2 |
-
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/[email protected].
|
|
|
1 |
git+https://huggingface.co/spaces/Wauplin/gradio-user-history
|
2 |
+
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/[email protected].3
|
src/gradio_user_history/_user_history.py
CHANGED
@@ -45,7 +45,6 @@ def render() -> None:
|
|
45 |
|
46 |
with gr.Row():
|
47 |
gr.LoginButton(min_width=250)
|
48 |
-
gr.LogoutButton(min_width=250)
|
49 |
refresh_button = gr.Button(
|
50 |
"Refresh",
|
51 |
icon="https://huggingface.co/spaces/Wauplin/gradio-user-history/resolve/main/assets/icon_refresh.png",
|
|
|
45 |
|
46 |
with gr.Row():
|
47 |
gr.LoginButton(min_width=250)
|
|
|
48 |
refresh_button = gr.Button(
|
49 |
"Refresh",
|
50 |
icon="https://huggingface.co/spaces/Wauplin/gradio-user-history/resolve/main/assets/icon_refresh.png",
|