Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ def check_and_refresh_dataset():
|
|
47 |
# Initial dataset load
|
48 |
load_and_prepare_dataset()
|
49 |
|
50 |
-
# Load
|
51 |
dataset = load_dataset(
|
52 |
"taesiri/PhotoshopRequest-DailyDump",
|
53 |
split="train",
|
@@ -79,8 +79,8 @@ reshuffle_dataset() # Initial shuffle
|
|
79 |
def get_next_samples(num_samples=5):
|
80 |
"""
|
81 |
Fetch 'num_samples' items from the dataset and return
|
82 |
-
the text
|
83 |
-
This
|
84 |
"""
|
85 |
check_and_refresh_dataset()
|
86 |
|
@@ -133,39 +133,50 @@ with gr.Blocks() as demo:
|
|
133 |
gr.Markdown(
|
134 |
"""
|
135 |
This is a preview of the PhotoshopRequest dataset. Each sample represents a Photoshop editing request post.
|
136 |
-
Click the 'Sample New Item' button to retrieve 5 random samples from the dataset
|
|
|
|
|
|
|
|
|
137 |
"""
|
138 |
)
|
139 |
|
140 |
-
# We
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
with gr.Row():
|
143 |
-
|
144 |
-
|
145 |
-
source_image1 = gr.Image(label="Source Image 1")
|
146 |
-
edited_image1 = gr.Image(label="Edited Image 1")
|
147 |
-
with gr.Column():
|
148 |
-
post_info2 = gr.Markdown()
|
149 |
-
source_image2 = gr.Image(label="Source Image 2")
|
150 |
-
edited_image2 = gr.Image(label="Edited Image 2")
|
151 |
-
with gr.Column():
|
152 |
-
post_info3 = gr.Markdown()
|
153 |
-
source_image3 = gr.Image(label="Source Image 3")
|
154 |
-
edited_image3 = gr.Image(label="Edited Image 3")
|
155 |
-
with gr.Column():
|
156 |
-
post_info4 = gr.Markdown()
|
157 |
-
source_image4 = gr.Image(label="Source Image 4")
|
158 |
-
edited_image4 = gr.Image(label="Edited Image 4")
|
159 |
-
with gr.Column():
|
160 |
-
post_info5 = gr.Markdown()
|
161 |
-
source_image5 = gr.Image(label="Source Image 5")
|
162 |
-
edited_image5 = gr.Image(label="Edited Image 5")
|
163 |
|
164 |
sample_button = gr.Button("Sample New Item")
|
165 |
info_md = gr.Markdown()
|
166 |
|
167 |
-
#
|
168 |
-
# which we map to our 15 output components in the same order:
|
169 |
sample_button.click(
|
170 |
get_next_samples,
|
171 |
outputs=[
|
|
|
47 |
# Initial dataset load
|
48 |
load_and_prepare_dataset()
|
49 |
|
50 |
+
# (Optional) Load a different dataset for variety, as in your original code:
|
51 |
dataset = load_dataset(
|
52 |
"taesiri/PhotoshopRequest-DailyDump",
|
53 |
split="train",
|
|
|
79 |
def get_next_samples(num_samples=5):
|
80 |
"""
|
81 |
Fetch 'num_samples' items from the dataset and return
|
82 |
+
the text + source/edited images for each sample.
|
83 |
+
This yields 3 * num_samples outputs in a fixed order.
|
84 |
"""
|
85 |
check_and_refresh_dataset()
|
86 |
|
|
|
133 |
gr.Markdown(
|
134 |
"""
|
135 |
This is a preview of the PhotoshopRequest dataset. Each sample represents a Photoshop editing request post.
|
136 |
+
Click the 'Sample New Item' button to retrieve **5 random samples** from the dataset.
|
137 |
+
|
138 |
+
**Layout**: For each sample, you'll see:
|
139 |
+
1. A text block with the post info.
|
140 |
+
2. A row with two images (source on the left, edited on the right).
|
141 |
"""
|
142 |
)
|
143 |
|
144 |
+
# We'll define 5 sets of outputs, each is: (Markdown, source_image, edited_image).
|
145 |
+
|
146 |
+
# Sample 1
|
147 |
+
post_info1 = gr.Markdown()
|
148 |
+
with gr.Row():
|
149 |
+
source_image1 = gr.Image(label="Source Image 1")
|
150 |
+
edited_image1 = gr.Image(label="Edited Image 1")
|
151 |
+
|
152 |
+
# Sample 2
|
153 |
+
post_info2 = gr.Markdown()
|
154 |
+
with gr.Row():
|
155 |
+
source_image2 = gr.Image(label="Source Image 2")
|
156 |
+
edited_image2 = gr.Image(label="Edited Image 2")
|
157 |
+
|
158 |
+
# Sample 3
|
159 |
+
post_info3 = gr.Markdown()
|
160 |
+
with gr.Row():
|
161 |
+
source_image3 = gr.Image(label="Source Image 3")
|
162 |
+
edited_image3 = gr.Image(label="Edited Image 3")
|
163 |
+
|
164 |
+
# Sample 4
|
165 |
+
post_info4 = gr.Markdown()
|
166 |
+
with gr.Row():
|
167 |
+
source_image4 = gr.Image(label="Source Image 4")
|
168 |
+
edited_image4 = gr.Image(label="Edited Image 4")
|
169 |
+
|
170 |
+
# Sample 5
|
171 |
+
post_info5 = gr.Markdown()
|
172 |
with gr.Row():
|
173 |
+
source_image5 = gr.Image(label="Source Image 5")
|
174 |
+
edited_image5 = gr.Image(label="Edited Image 5")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
sample_button = gr.Button("Sample New Item")
|
177 |
info_md = gr.Markdown()
|
178 |
|
179 |
+
# Map the outputs in the same order they are returned by get_next_samples
|
|
|
180 |
sample_button.click(
|
181 |
get_next_samples,
|
182 |
outputs=[
|