tori29umai commited on
Commit
06642da
1 Parent(s): 27419c1
Files changed (2) hide show
  1. app.py +3 -2
  2. utils/prompt_analysis.py +0 -41
app.py CHANGED
@@ -37,6 +37,7 @@ class Img2Img:
37
  self.default_nagative_prompt = "lowres, error, extra digit, fewer digits, cropped, worst quality,low quality, normal quality, jpeg artifacts, blurry"
38
  self.post_filter = True
39
  self.tagger_model = None
 
40
 
41
  def setup_paths(self):
42
  self.path = os.getcwd()
@@ -54,7 +55,7 @@ class Img2Img:
54
  load_lora_model(self.lora_dir)
55
 
56
 
57
- def prompt_layout(self, input_image_path):
58
  with gr.Column():
59
  with gr.Row():
60
  self.prompt = gr.Textbox(label="prompt", lines=3)
@@ -65,7 +66,7 @@ class Img2Img:
65
 
66
  self.prompt_analysis_button.click(
67
  self.process_prompt_analysis,
68
- inputs=[input_image_path],
69
  outputs=self.prompt
70
  )
71
  return [self.prompt, self.negative_prompt]
 
37
  self.default_nagative_prompt = "lowres, error, extra digit, fewer digits, cropped, worst quality,low quality, normal quality, jpeg artifacts, blurry"
38
  self.post_filter = True
39
  self.tagger_model = None
40
+ self.input_image_path = None
41
 
42
  def setup_paths(self):
43
  self.path = os.getcwd()
 
55
  load_lora_model(self.lora_dir)
56
 
57
 
58
+ def prompt_layout(self):
59
  with gr.Column():
60
  with gr.Row():
61
  self.prompt = gr.Textbox(label="prompt", lines=3)
 
66
 
67
  self.prompt_analysis_button.click(
68
  self.process_prompt_analysis,
69
+ inputs=[self.input_image_path],
70
  outputs=self.prompt
71
  )
72
  return [self.prompt, self.negative_prompt]
utils/prompt_analysis.py DELETED
@@ -1,41 +0,0 @@
1
- import os
2
-
3
- import gradio as gr
4
-
5
- from utils.prompt_utils import remove_color
6
- from utils.tagger import modelLoad, analysis
7
-
8
-
9
- class PromptAnalysis:
10
- def __init__(self, model_dir, post_filter=True,
11
- default_nagative_prompt="lowres, error, extra digit, fewer digits, cropped, worst quality, "
12
- "low quality, normal quality, jpeg artifacts, blurry"):
13
- self.default_nagative_prompt = default_nagative_prompt
14
- self.post_filter = post_filter
15
- self.model = None
16
- self.model_dir = model_dir
17
-
18
- def layout(self, input_image_path):
19
- with gr.Column():
20
- with gr.Row():
21
- self.prompt = gr.Textbox(label="prompt", lines=3)
22
- with gr.Row():
23
- self.negative_prompt = gr.Textbox(label="negative_prompt", lines=3, value=self.default_nagative_prompt)
24
- with gr.Row():
25
- self.prompt_analysis_button = gr.Button("prompt解析")
26
-
27
- self.prompt_analysis_button.click(
28
- self.process_prompt_analysis,
29
- inputs=[input_image_path],
30
- outputs=self.prompt
31
- )
32
- return [self.prompt, self.negative_prompt]
33
-
34
- def process_prompt_analysis(self, input_image_path):
35
- if self.model is None:
36
- self.model = modelLoad(self.model_dir)
37
- tags = analysis(input_image_path, self.model_dir, self.model)
38
- tags_list = tags
39
- if self.post_filter:
40
- tags_list = remove_color(tags)
41
- return tags_list