panelforge commited on
Commit
90d2a01
·
verified ·
1 Parent(s): d16d2c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -23,6 +23,7 @@ MAX_IMAGE_SIZE = 1024
23
  @spaces.GPU # [uncomment to use ZeroGPU]
24
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, use_tags, progress=gr.Progress(track_tqdm=True)):
25
 
 
26
  if use_tags:
27
  selected_tags_1 = [tag_options_1[tag] for tag in tag_selection_1 if tag in tag_options_1]
28
  selected_tags_2 = [tag_options_2[tag] for tag in tag_selection_2 if tag in tag_options_2]
@@ -31,14 +32,19 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
31
  else:
32
  final_prompt = f'score_9, score_8_up, score_7_up, source_anime, {prompt}'
33
 
 
 
 
 
34
  if randomize_seed:
35
  seed = random.randint(0, MAX_SEED)
36
 
37
  generator = torch.Generator().manual_seed(seed)
38
 
 
39
  image = pipe(
40
  prompt=final_prompt,
41
- negative_prompt='worst quality, bad quality, jpeg artifacts, source_cartoon, 3d, (censor), monochrome, blurry, lowres, watermark, ' + negative_prompt,
42
  guidance_scale=guidance_scale,
43
  num_inference_steps=num_inference_steps,
44
  width=width,
@@ -47,7 +53,8 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
47
  ).images[0]
48
 
49
  # Return image, seed, and the used prompts
50
- return image, seed, f"Prompt used: {final_prompt}\nNegative prompt used: {negative_prompt}"
 
51
 
52
  examples = [
53
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
 
23
  @spaces.GPU # [uncomment to use ZeroGPU]
24
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, use_tags, progress=gr.Progress(track_tqdm=True)):
25
 
26
+ # Determine final prompt
27
  if use_tags:
28
  selected_tags_1 = [tag_options_1[tag] for tag in tag_selection_1 if tag in tag_options_1]
29
  selected_tags_2 = [tag_options_2[tag] for tag in tag_selection_2 if tag in tag_options_2]
 
32
  else:
33
  final_prompt = f'score_9, score_8_up, score_7_up, source_anime, {prompt}'
34
 
35
+ # Concatenate user-provided negative prompt with additional restrictions
36
+ additional_negatives = "worst quality, bad quality, jpeg artifacts, source_cartoon, 3d, (censor), monochrome, blurry, lowres, watermark"
37
+ full_negative_prompt = f"{additional_negatives}, {negative_prompt}"
38
+
39
  if randomize_seed:
40
  seed = random.randint(0, MAX_SEED)
41
 
42
  generator = torch.Generator().manual_seed(seed)
43
 
44
+ # Generate the image with the final prompts
45
  image = pipe(
46
  prompt=final_prompt,
47
+ negative_prompt=full_negative_prompt,
48
  guidance_scale=guidance_scale,
49
  num_inference_steps=num_inference_steps,
50
  width=width,
 
53
  ).images[0]
54
 
55
  # Return image, seed, and the used prompts
56
+ return image, seed, f"Prompt used: {final_prompt}\nNegative prompt used: {full_negative_prompt}"
57
+
58
 
59
  examples = [
60
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",