tori29umai commited on
Commit
369edb1
1 Parent(s): 5110943

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -1,3 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  @spaces.GPU(duration=120)
2
  def predict(lora_model, input_image_path, prompt, negative_prompt, controlnet_scale, load_model_fn):
3
  # LoRAモデルに基づきpipeを取得
 
1
+ import spaces
2
+ import gradio as gr
3
+ import torch
4
+ from diffusers import ControlNetModel, StableDiffusionXLControlNetImg2ImgPipeline, AutoencoderKL
5
+ from PIL import Image
6
+ import os
7
+ import time
8
+ from utils.dl_utils import dl_cn_model, dl_cn_config, dl_tagger_model, dl_lora_model
9
+ from utils.image_utils import resize_image_aspect_ratio, base_generation, background_removal
10
+ from utils.prompt_utils import execute_prompt, remove_color, remove_duplicates
11
+ from utils.tagger import modelLoad, analysis
12
+
13
+ path = os.getcwd()
14
+ cn_dir = f"{path}/controlnet"
15
+ tagger_dir = f"{path}/tagger"
16
+ lora_dir = f"{path}/lora"
17
+ os.makedirs(cn_dir, exist_ok=True)
18
+ os.makedirs(tagger_dir, exist_ok=True)
19
+ os.makedirs(lora_dir, exist_ok=True)
20
+
21
+ dl_cn_model(cn_dir)
22
+ dl_cn_config(cn_dir)
23
+ dl_tagger_model(tagger_dir)
24
+ dl_lora_model(lora_dir)
25
+
26
  @spaces.GPU(duration=120)
27
  def predict(lora_model, input_image_path, prompt, negative_prompt, controlnet_scale, load_model_fn):
28
  # LoRAモデルに基づきpipeを取得