Spaces:
Running
Running
Fix image_path error
Browse files- app.py +3 -3
- src/gradio_user_history/_user_history.py +1 -1
app.py
CHANGED
@@ -51,7 +51,7 @@ def generate(prompt: str, negprompt: str, profile: gr.OAuthProfile | None) -> tu
|
|
51 |
return [generated_img_path] # type: ignore
|
52 |
|
53 |
|
54 |
-
with gr.Blocks(css="style.css") as demo:
|
55 |
with gr.Group():
|
56 |
prompt = gr.Text(show_label=False, placeholder="Prompt")
|
57 |
negprompt = gr.Text(show_label=False, placeholder="Negative Prompt")
|
@@ -66,11 +66,11 @@ with gr.Blocks(css="style.css") as demo:
|
|
66 |
|
67 |
with gr.Blocks() as demo_with_history:
|
68 |
with gr.Tab("README"):
|
69 |
-
gr.Markdown(Path("README.md").read_text().split("---")[-1])
|
70 |
with gr.Tab("Demo"):
|
71 |
demo.render()
|
72 |
with gr.Tab("Past generations"):
|
73 |
gr_user_history.render()
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
-
demo_with_history.queue().launch()
|
|
|
51 |
return [generated_img_path] # type: ignore
|
52 |
|
53 |
|
54 |
+
with gr.Blocks(css="style.css", theme='Surn/beeuty@==0.5.12') as demo:
|
55 |
with gr.Group():
|
56 |
prompt = gr.Text(show_label=False, placeholder="Prompt")
|
57 |
negprompt = gr.Text(show_label=False, placeholder="Negative Prompt")
|
|
|
66 |
|
67 |
with gr.Blocks() as demo_with_history:
|
68 |
with gr.Tab("README"):
|
69 |
+
gr.Markdown(Path("README.md").read_text(encoding="utf-8").split("---")[-1])
|
70 |
with gr.Tab("Demo"):
|
71 |
demo.render()
|
72 |
with gr.Tab("Past generations"):
|
73 |
gr_user_history.render()
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
+
demo_with_history.queue().launch(allowed_paths=["data/_user_history"])
|
src/gradio_user_history/_user_history.py
CHANGED
@@ -156,7 +156,7 @@ def save_image(
|
|
156 |
metadata = {}
|
157 |
if "datetime" not in metadata:
|
158 |
metadata["datetime"] = str(datetime.now())
|
159 |
-
data = {"
|
160 |
with user_history._user_lock(username):
|
161 |
with user_history._user_jsonl_path(username).open("a") as f:
|
162 |
f.write(json.dumps(data) + "\n")
|
|
|
156 |
metadata = {}
|
157 |
if "datetime" not in metadata:
|
158 |
metadata["datetime"] = str(datetime.now())
|
159 |
+
data = {"image_path": str(image_path), "label": label, "metadata": metadata}
|
160 |
with user_history._user_lock(username):
|
161 |
with user_history._user_jsonl_path(username).open("a") as f:
|
162 |
f.write(json.dumps(data) + "\n")
|