tori29umai commited on
Commit
19fe834
1 Parent(s): 7771f33
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -33,7 +33,6 @@ class Img2Img:
33
  def __init__(self):
34
  self.setup_paths()
35
  self.setup_models()
36
- self.demo = self.layout()
37
  self.post_filter = True
38
  self.tagger_model = None
39
  self.input_image_path = None
@@ -64,7 +63,7 @@ class Img2Img:
64
  return tags_list
65
 
66
 
67
- def layout(self):
68
  css = """
69
  #intro{
70
  max-width: 32rem;
@@ -97,13 +96,11 @@ class Img2Img:
97
  inputs=[self.input_image_path, self.prompt, self.negative_prompt, self.controlnet_scale],
98
  outputs=self.output_image
99
  )
100
-
101
  self.demo.queue()
102
  self.demo.launch(share=True)
103
 
104
  @spaces.GPU
105
  def predict(self, input_image_path, prompt, negative_prompt, controlnet_scale):
106
- # モデルのロードをここに移動
107
  pipe = load_model(self.lora_dir, self.cn_dir)
108
  input_image_pil = Image.open(input_image_path)
109
  base_size = input_image_pil.size
@@ -133,3 +130,7 @@ class Img2Img:
133
  print(f"Time taken: {time.time() - last_time}")
134
  output_image = output_image.resize(base_size, Image.LANCZOS)
135
  return output_image
 
 
 
 
 
33
  def __init__(self):
34
  self.setup_paths()
35
  self.setup_models()
 
36
  self.post_filter = True
37
  self.tagger_model = None
38
  self.input_image_path = None
 
63
  return tags_list
64
 
65
 
66
+ def launch(self):
67
  css = """
68
  #intro{
69
  max-width: 32rem;
 
96
  inputs=[self.input_image_path, self.prompt, self.negative_prompt, self.controlnet_scale],
97
  outputs=self.output_image
98
  )
 
99
  self.demo.queue()
100
  self.demo.launch(share=True)
101
 
102
  @spaces.GPU
103
  def predict(self, input_image_path, prompt, negative_prompt, controlnet_scale):
 
104
  pipe = load_model(self.lora_dir, self.cn_dir)
105
  input_image_pil = Image.open(input_image_path)
106
  base_size = input_image_pil.size
 
130
  print(f"Time taken: {time.time() - last_time}")
131
  output_image = output_image.resize(base_size, Image.LANCZOS)
132
  return output_image
133
+
134
+ if __name__ == "__main__":
135
+ ui = Img2Img()
136
+ ui.launch(share=False)