tori29umai commited on
Commit
3f5a0c2
1 Parent(s): 65e51cd
Files changed (2) hide show
  1. app.py +8 -7
  2. utils/prompt_analysis.py +2 -2
app.py CHANGED
@@ -74,13 +74,14 @@ pipe = pipe.to(device)
74
 
75
  @spaces.GPU
76
  def predict(
77
- input_image,
78
  prompt,
79
  negative_prompt,
80
  controlnet_conditioning_scale,
81
  ):
82
- base_size =input_image.size
83
- resize_image= resize_image_aspect_ratio(input_image)
 
84
  resize_image_size = resize_image.size
85
  width = resize_image_size[0]
86
  height = resize_image_size[1]
@@ -126,12 +127,12 @@ with gr.Blocks(css=css) as demo:
126
  # 画像アップロード用の行
127
  with gr.Row():
128
  with gr.Column():
129
- input_image = gr.Image(label="入力画像", type="pil")
130
 
131
  # プロンプト入力用の行
132
  with gr.Row():
133
  prompt_analysis = PromptAnalysis(tagger_dir)
134
- [prompt, nega] = PromptAnalysis.layout(input_image)
135
  # 画像の詳細設定用のスライダー行
136
  with gr.Row():
137
  controlnet_conditioning_scale = gr.Slider(minimum=0.5, maximum=1.25, value=1.0, step=0.01, interactive=True, label="線画忠実度")
@@ -145,7 +146,7 @@ with gr.Blocks(css=css) as demo:
145
 
146
  # インプットとアウトプットの設定
147
  inputs = [
148
- input_image,
149
  prompt,
150
  nega,
151
  controlnet_conditioning_scale,
@@ -155,7 +156,7 @@ with gr.Blocks(css=css) as demo:
155
  # ボタンのクリックイベントを設定
156
  generate_button.click(
157
  fn=predict,
158
- inputs=[input_image, prompt, nega, controlnet_conditioning_scale],
159
  outputs=[output_image]
160
  )
161
 
 
74
 
75
  @spaces.GPU
76
  def predict(
77
+ input_image_path,
78
  prompt,
79
  negative_prompt,
80
  controlnet_conditioning_scale,
81
  ):
82
+ input_image_pil = Image.open(input_image_path)
83
+ base_size =input_image_pil.size
84
+ resize_image= resize_image_aspect_ratio(input_image_pil)
85
  resize_image_size = resize_image.size
86
  width = resize_image_size[0]
87
  height = resize_image_size[1]
 
127
  # 画像アップロード用の行
128
  with gr.Row():
129
  with gr.Column():
130
+ input_image_path = gr.Image(label="入力画像", type='filepath')
131
 
132
  # プロンプト入力用の行
133
  with gr.Row():
134
  prompt_analysis = PromptAnalysis(tagger_dir)
135
+ [prompt, nega] = PromptAnalysis.layout(input_image_path)
136
  # 画像の詳細設定用のスライダー行
137
  with gr.Row():
138
  controlnet_conditioning_scale = gr.Slider(minimum=0.5, maximum=1.25, value=1.0, step=0.01, interactive=True, label="線画忠実度")
 
146
 
147
  # インプットとアウトプットの設定
148
  inputs = [
149
+ input_image_path,
150
  prompt,
151
  nega,
152
  controlnet_conditioning_scale,
 
156
  # ボタンのクリックイベントを設定
157
  generate_button.click(
158
  fn=predict,
159
+ inputs=[input_image_path, prompt, nega, controlnet_conditioning_scale],
160
  outputs=[output_image]
161
  )
162
 
utils/prompt_analysis.py CHANGED
@@ -15,7 +15,7 @@ class PromptAnalysis:
15
  self.model = None
16
  self.model_dir = model_dir
17
 
18
- def layout(self, input_image):
19
  with gr.Column():
20
  with gr.Row():
21
  self.prompt = gr.Textbox("prompt", lines=3)
@@ -26,7 +26,7 @@ class PromptAnalysis:
26
 
27
  self.prompt_analysis_button.click(
28
  self.process_prompt_analysis,
29
- inputs=[input_image],
30
  outputs=self.prompt
31
  )
32
  return [self.prompt, self.negative_prompt]
 
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("prompt", lines=3)
 
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]