weathon commited on
Commit
bc3f915
·
1 Parent(s): 97bcee3

add preset for vsf

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -79,7 +79,30 @@ with open("sample_prompts.json", "r") as f:
79
  def load_sample():
80
  sample = np.random.choice(sample_prompts)
81
  return sample['prompt'], sample['missing_element']
82
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  with gr.Blocks(title="Value Sign Flip SD3.5 Demo") as demo:
85
  gr.Markdown("# Value Sign Flip SD3.5 Demo \n\n This demo is based on SD3.5-L-Turbo model and uses Value Sign Flip technique to generate videos with different guidance scales and biases. More on [GitHub](https://github.com/weathon/VSF/blob/main/wan.md)\n\nPositive prompt should be at least 1 sentence long or the results will be weird.")
@@ -89,6 +112,7 @@ with gr.Blocks(title="Value Sign Flip SD3.5 Demo") as demo:
89
  pos = gr.Textbox(label="Positive Prompt", value="A polished bicycle frame leans against a weathered brick wall under soft morning light.")
90
  neg = gr.Textbox(label="Negative Prompt", value="wheels")
91
  sample = gr.Button("Load A Sample Prompt")
 
92
  sample.click(fn=load_sample, inputs=[], outputs=[pos, neg])
93
 
94
  with gr.Row():
@@ -97,6 +121,10 @@ with gr.Blocks(title="Value Sign Flip SD3.5 Demo") as demo:
97
  bias = gr.Slider(0, 0.5, step=0.01, label="Bias", value=0.1)
98
  step = gr.Slider(4, 15, step=1, label="Step", value=8)
99
  seed = gr.Number(label="Seed", value=0, precision=0)
 
 
 
 
100
 
101
  with gr.Row():
102
  gr.Markdown("## NAG Generation Parameters")
 
79
  def load_sample():
80
  sample = np.random.choice(sample_prompts)
81
  return sample['prompt'], sample['missing_element']
82
+
83
+ from openai import OpenAI
84
+
85
+ client = OpenAI(
86
+ base_url="https://openrouter.ai/api/v1",
87
+ api_key=os.environ.get("or", None),
88
+ )
89
+
90
+
91
+ # def rephrase_prompt(pos_prompt, neg_prompt):
92
+ # completion = client.chat.completions.create(
93
+ # extra_headers={
94
+ # "HTTP-Referer": "<YOUR_SITE_URL>", # Optional. Site URL for rankings on openrouter.ai.
95
+ # "X-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
96
+ # },
97
+ # extra_body={},
98
+ # model="qwen/qwen3-vl-235b-a22b-instruct",
99
+ # messages=[
100
+ # {
101
+ # "role": "user",
102
+ # "content": "Repahrase the following prompt to one sentence for positive prompt and a few words for negative prompt.\n\nOriginal Prompt: {}\n\nNegative Element: {}. \n make sure the generated prompt follows the positive-negative prompt pair, do not mention the negative prompt in positive one".format(pos_prompt, neg_prompt)
103
+ # }
104
+ # ]
105
+ # )
106
 
107
  with gr.Blocks(title="Value Sign Flip SD3.5 Demo") as demo:
108
  gr.Markdown("# Value Sign Flip SD3.5 Demo \n\n This demo is based on SD3.5-L-Turbo model and uses Value Sign Flip technique to generate videos with different guidance scales and biases. More on [GitHub](https://github.com/weathon/VSF/blob/main/wan.md)\n\nPositive prompt should be at least 1 sentence long or the results will be weird.")
 
112
  pos = gr.Textbox(label="Positive Prompt", value="A polished bicycle frame leans against a weathered brick wall under soft morning light.")
113
  neg = gr.Textbox(label="Negative Prompt", value="wheels")
114
  sample = gr.Button("Load A Sample Prompt")
115
+ # rephase = gr.Button("Rephrase Prompt")
116
  sample.click(fn=load_sample, inputs=[], outputs=[pos, neg])
117
 
118
  with gr.Row():
 
121
  bias = gr.Slider(0, 0.5, step=0.01, label="Bias", value=0.1)
122
  step = gr.Slider(4, 15, step=1, label="Step", value=8)
123
  seed = gr.Number(label="Seed", value=0, precision=0)
124
+ set_strong_vsf = gr.Button("Set to VSF Strong Settings")
125
+ set_strong_vsf.click(fn=lambda : (3.8, 0.2), inputs=[], outputs=[guidance, bias])
126
+ set_mild_vsf = gr.Button("Set to VSF Quality Settings")
127
+ set_mild_vsf.click(fn=lambda : (3.3, 0.2), inputs=[], outputs=[guidance, bias])
128
 
129
  with gr.Row():
130
  gr.Markdown("## NAG Generation Parameters")