RohitGandikota commited on
Commit
0f50532
·
verified ·
1 Parent(s): b4c8ed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -8
app.py CHANGED
@@ -230,6 +230,67 @@ SPACE_ID = os.getenv('SPACE_ID')
230
  SHARED_UI_WARNING = f'''## You can duplicate and use it with a gpu with at least 24GB, or clone this repository to run on your own machine.
231
  <center><a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="margin-top:0;margin-bottom:0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></center>
232
  '''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
 
234
  with gr.Blocks(css=css) as demo:
235
  with gr.Column(elem_id="col-container"):
@@ -240,14 +301,17 @@ with gr.Blocks(css=css) as demo:
240
  💻 [GitHub Code](https://github.com/rohitgandikota/sliderspace)
241
  """)
242
 
243
- gr.Markdown("""
244
- User Guide: We released sliderspace directions for a few concepts. To test them: <br>
245
- 1. Choose the concept from the `SliderSpace trained on` menu. (eg. "Wizard")
246
- 2. Select one of the many directions we discovered for that concept from the `Discovered Directions` menu. (eg. "Direction 3")
247
- 3. Choose a slider weight between -1 to 1 (recommended). But feel free to explore the scale (eg. +1.5)
248
- 4. Finally, write a prompt for the concept you chose. (eg. "picture of a wizard fighting a magical war")
249
- 5. Click Generate and discover what the direction is !!
250
- """)
 
 
 
251
 
252
  with gr.Row():
253
  prompt = gr.Text(
 
230
  SHARED_UI_WARNING = f'''## You can duplicate and use it with a gpu with at least 24GB, or clone this repository to run on your own machine.
231
  <center><a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="margin-top:0;margin-bottom:0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></center>
232
  '''
233
+ # Simple instructions (original)
234
+ simple_instructions = """ User Guide: We released sliderspace directions for a few concepts. To test them: <br>
235
+ - Choose the concept from the `SliderSpace trained on` menu. (eg. "Wizard")
236
+ - Select one of the many directions we discovered for that concept from the `Discovered Directions` menu. (eg. "Direction 3")
237
+ - Choose a slider weight between -1 to 1 (recommended). But feel free to explore the scale (eg. +1.5)
238
+ - Finally, write a prompt for the concept you chose. (eg. "picture of a wizard fighting a magical war")
239
+ - Click Generate and discover what the direction is !! """
240
+
241
+ # Detailed instructions
242
+ detailed_instructions = """# SliderSpace User Guide
243
+
244
+ ## Overview
245
+ SliderSpace allows you to explore diffusion model knowledge's concept directions. This tool helps you discover how different "directions" in the latent space can influence image generation for specific concepts.
246
+
247
+ ## Detailed Navigation Instructions
248
+
249
+ ### Step 1: Select Your Concept
250
+ - Locate the dropdown menu labeled `SliderSpace trained on`
251
+ - Click to expand the menu and view all available concept categories
252
+ - Select the concept you want to explore (e.g., "Wizard", "Animal", "Landscape")
253
+ - Each concept has been pre-trained with multiple discoverable directions
254
+
255
+ ### Step 2: Choose a Direction to Explore
256
+ - Find the `Discovered Directions` dropdown menu
257
+ - Click to view all available directions for your selected concept
258
+ - Select one of the numbered directions (e.g., "Direction 3")
259
+ - Each direction represents a different aspect or variation of the concept
260
+ - Try multiple directions to see how they affect your results
261
+
262
+ ### Step 3: Adjust the Slider Weight
263
+ - Locate the slider control for weight adjustment
264
+ - Move the slider to set a value between -1 and 1 (this is the recommended range)
265
+ - Negative values (-1 to 0) will move away from the direction
266
+ - Positive values (0 to 1) will enhance the direction
267
+ - For experimental results, you can try more extreme values (e.g., +1.5 or -1.5)
268
+ - The weight determines how strongly the direction influences your generated image
269
+
270
+ ### Step 4: Write Your Prompt
271
+ - Enter a text prompt in the provided text field
272
+ - Make sure your prompt relates to the concept you selected in Step 1
273
+ - Be specific about what you want to see (e.g., "picture of a wizard fighting a magical war")
274
+ - The prompt works together with the direction and weight to generate the final image
275
+
276
+ ### Step 5: Generate and Analyze
277
+ - Click the `Generate` button to create your image
278
+ - Observe how the selected direction affects the output
279
+ - Compare results with different directions and weights to understand each direction's effect
280
+ - Use these observations to discover what each direction represents in the latent space
281
+
282
+ ## Tips for Best Results
283
+ - Keep notes on which directions create specific effects
284
+ - Try the same prompt with different directions to see varied results
285
+ - Experiment with subtle weight changes for fine-tuning
286
+ - Some directions work better with specific types of prompts
287
+
288
+ ## Troubleshooting
289
+ - If results aren't as expected, try adjusting the weight to a more moderate value
290
+ - Ensure your prompt clearly relates to the selected concept
291
+ - Try multiple directions if you're not seeing the effect you want
292
+ """
293
+
294
 
295
  with gr.Blocks(css=css) as demo:
296
  with gr.Column(elem_id="col-container"):
 
301
  💻 [GitHub Code](https://github.com/rohitgandikota/sliderspace)
302
  """)
303
 
304
+ with gr.Row():
305
+ instructions_md = gr.Markdown(simple_instructions)
306
+ toggle_btn = gr.Button("Show Detailed Instructions")
307
+
308
+ # Toggle button to switch between simple and detailed instructions
309
+ toggle_btn.click(
310
+ fn=toggle_instructions,
311
+ inputs=[gr.State(False)],
312
+ outputs=[instructions_md, toggle_btn],
313
+ _js="(x) => !x" # Toggle the state
314
+ )
315
 
316
  with gr.Row():
317
  prompt = gr.Text(