visualizingjp commited on
Commit
4b87716
·
verified ·
1 Parent(s): 3784ad6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import spaces
2
  import torch
3
  import gradio as gr
@@ -25,6 +27,10 @@ import os
25
  from transformers import CLIPImageProcessor
26
  from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
27
 
 
 
 
 
28
  BASE_MODEL = "SG161222/Realistic_Vision_V5.1_noVAE"
29
 
30
  # Initialize both pipelines
@@ -48,6 +54,10 @@ main_pipe = StableDiffusionControlNetPipeline.from_pretrained(
48
  torch_dtype=torch.float16,
49
  ).to("cuda")
50
 
 
 
 
 
51
  # Function to check NSFW images
52
  #def check_nsfw_images(images: list[Image.Image]) -> tuple[list[Image.Image], list[bool]]:
53
  # if SAFETY_CHECKER_ENABLED:
@@ -134,7 +144,11 @@ def convert_to_base64(pil_image):
134
  image.save(temp_file.name)
135
  return temp_file.name
136
 
 
 
 
137
  # Inference function
 
138
  @spaces.GPU
139
  def inference(
140
  control_image: Image.Image,
@@ -216,7 +230,11 @@ def inference(
216
  )
217
 
218
  return out_image["images"][0], gr.update(visible=True), gr.update(visible=True), my_seed
219
-
 
 
 
 
220
  with gr.Blocks() as app:
221
  gr.Markdown(
222
  '''
 
1
+ # インポートと初期設定
2
+
3
  import spaces
4
  import torch
5
  import gradio as gr
 
27
  from transformers import CLIPImageProcessor
28
  from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
29
 
30
+
31
+
32
+ # モデルの初期化
33
+
34
  BASE_MODEL = "SG161222/Realistic_Vision_V5.1_noVAE"
35
 
36
  # Initialize both pipelines
 
54
  torch_dtype=torch.float16,
55
  ).to("cuda")
56
 
57
+
58
+
59
+ # 関数の定義
60
+
61
  # Function to check NSFW images
62
  #def check_nsfw_images(images: list[Image.Image]) -> tuple[list[Image.Image], list[bool]]:
63
  # if SAFETY_CHECKER_ENABLED:
 
144
  image.save(temp_file.name)
145
  return temp_file.name
146
 
147
+
148
+
149
+ # 推論関数
150
  # Inference function
151
+
152
  @spaces.GPU
153
  def inference(
154
  control_image: Image.Image,
 
230
  )
231
 
232
  return out_image["images"][0], gr.update(visible=True), gr.update(visible=True), my_seed
233
+
234
+
235
+
236
+ # Gradio UIの構築
237
+
238
  with gr.Blocks() as app:
239
  gr.Markdown(
240
  '''