Spaces:
Runtime error
Runtime error
Add info
Browse files
app.py
CHANGED
|
@@ -99,6 +99,45 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 99 |
selected_index = gr.Number(visible=False, precision=0)
|
| 100 |
save_preference_button = gr.Button('Save preference', interactive=False)
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
prompt.submit(
|
| 103 |
fn=generate,
|
| 104 |
inputs=prompt,
|
|
|
|
| 99 |
selected_index = gr.Number(visible=False, precision=0)
|
| 100 |
save_preference_button = gr.Button('Save preference', interactive=False)
|
| 101 |
|
| 102 |
+
with gr.Accordion(label='About this Space', open=False):
|
| 103 |
+
gr.Markdown('''
|
| 104 |
+
This Space is a sample Space that collects user preferences for the results generated by a diffusion model.
|
| 105 |
+
This demo calls the [stable diffusion Space](https://huggingface.co/spaces/stabilityai/stable-diffusion) with the [`gradio_client`](https://pypi.org/project/gradio-client/) library.
|
| 106 |
+
|
| 107 |
+
The user preference data is periodically zipped and uploaded to [this dataset repo](https://huggingface.co/datasets/hysts-samples/sample-user-preferences).
|
| 108 |
+
The directory structure of the zipped data is as follows:
|
| 109 |
+
```
|
| 110 |
+
results
|
| 111 |
+
├── 11e11b01-3388-48b3-a2ab-1b58d156e466
|
| 112 |
+
│ ├── 000.jpg
|
| 113 |
+
│ ├── 001.jpg
|
| 114 |
+
│ ├── 002.jpg
|
| 115 |
+
│ ├── 003.jpg
|
| 116 |
+
│ └── preferences.json
|
| 117 |
+
├── 1470ec1d-67a1-47ae-ab9c-4e0e0594dadf
|
| 118 |
+
│ ├── 000.jpg
|
| 119 |
+
│ ├── 001.jpg
|
| 120 |
+
│ ├── 002.jpg
|
| 121 |
+
│ ├── 003.jpg
|
| 122 |
+
│ └── preferences.json
|
| 123 |
+
...
|
| 124 |
+
```
|
| 125 |
+
Also, each `preferences.json` looks like this:
|
| 126 |
+
```
|
| 127 |
+
{
|
| 128 |
+
"prompt": "an astronaut riding a horse",
|
| 129 |
+
"negative_prompt": "",
|
| 130 |
+
"guidance_scale": 9,
|
| 131 |
+
"selected_index": 2,
|
| 132 |
+
"timestamp": "2023-06-15T07:57:00.097883"
|
| 133 |
+
}
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
The periodic upload is done using [`huggingface_hub.CommitScheduler`](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.CommitScheduler).
|
| 138 |
+
See [this Space](https://huggingface.co/spaces/Wauplin/space_to_dataset_saver) for more general usage.
|
| 139 |
+
''')
|
| 140 |
+
|
| 141 |
prompt.submit(
|
| 142 |
fn=generate,
|
| 143 |
inputs=prompt,
|