BertChristiaens commited on
Commit
a54498b
1 Parent(s): 13e5061
Files changed (3) hide show
  1. app.py +1 -10
  2. models.py +3 -6
  3. models_stub.py +0 -25
app.py CHANGED
@@ -7,15 +7,7 @@ import numpy as np
7
  import os
8
  import time
9
 
10
- # get OS environment variables of EMULATED
11
- EMULATED = os.environ.get('EMULATED', False)
12
- print(EMULATED)
13
-
14
- if not EMULATED:
15
- from models import make_image_controlnet, make_inpainting, segment_image
16
- else:
17
- from models_stub import make_image_controlnet, make_inpainting, segment_image
18
-
19
  from config import HEIGHT, WIDTH, POS_PROMPT, NEG_PROMPT, COLOR_MAPPING, map_colors, map_colors_rgb
20
  from palette import COLOR_MAPPING_CATEGORY
21
  from preprocessing import preprocess_seg_mask, get_image, get_mask
@@ -35,7 +27,6 @@ def on_upload() -> None:
35
  del st.session_state['unique_colors']
36
 
37
 
38
-
39
  def check_reset_state() -> bool:
40
  """Check whether the UI elements need to be reset
41
  Returns:
 
7
  import os
8
  import time
9
 
10
+ from models import make_image_controlnet, make_inpainting, segment_image
 
 
 
 
 
 
 
 
11
  from config import HEIGHT, WIDTH, POS_PROMPT, NEG_PROMPT, COLOR_MAPPING, map_colors, map_colors_rgb
12
  from palette import COLOR_MAPPING_CATEGORY
13
  from preprocessing import preprocess_seg_mask, get_image, get_mask
 
27
  del st.session_state['unique_colors']
28
 
29
 
 
30
  def check_reset_state() -> bool:
31
  """Check whether the UI elements need to be reset
32
  Returns:
models.py CHANGED
@@ -75,8 +75,7 @@ def postprocess_image_masking(inpainted: Image, image: Image, mask: Image) -> Im
75
  return final_inpainted.convert("RGB")
76
 
77
 
78
- @st.experimental_singleton(max_entries=1)
79
- @st.cache_resource
80
  def get_controlnet() -> ControlNetModel:
81
  """Method to load the controlnet model
82
  Returns:
@@ -100,8 +99,7 @@ def get_controlnet() -> ControlNetModel:
100
  return pipe, compel_proc
101
 
102
 
103
- @st.experimental_singleton(max_entries=1)
104
- @st.cache_resource
105
  def get_segmentation_pipeline() -> Tuple[AutoImageProcessor, UperNetForSemanticSegmentation]:
106
  """Method to load the segmentation pipeline
107
  Returns:
@@ -113,8 +111,7 @@ def get_segmentation_pipeline() -> Tuple[AutoImageProcessor, UperNetForSemanticS
113
  return image_processor, image_segmentor
114
 
115
 
116
- @st.experimental_singleton(max_entries=1)
117
- @st.cache_resource
118
  def get_inpainting_pipeline() -> StableDiffusionInpaintPipeline:
119
  """Method to load the inpainting pipeline
120
  Returns:
 
75
  return final_inpainted.convert("RGB")
76
 
77
 
78
+ @st.experimental_singleton(max_entries=5)
 
79
  def get_controlnet() -> ControlNetModel:
80
  """Method to load the controlnet model
81
  Returns:
 
99
  return pipe, compel_proc
100
 
101
 
102
+ @st.experimental_singleton(max_entries=5)
 
103
  def get_segmentation_pipeline() -> Tuple[AutoImageProcessor, UperNetForSemanticSegmentation]:
104
  """Method to load the segmentation pipeline
105
  Returns:
 
111
  return image_processor, image_segmentor
112
 
113
 
114
+ @st.experimental_singleton(max_entries=5)
 
115
  def get_inpainting_pipeline() -> StableDiffusionInpaintPipeline:
116
  """Method to load the inpainting pipeline
117
  Returns:
models_stub.py DELETED
@@ -1,25 +0,0 @@
1
- import numpy as np
2
-
3
- def make_image_controlnet(image,
4
- mask_image,
5
- controlnet_conditioning_image,
6
- positive_prompt,
7
- negative_prompt,
8
- seed,
9
- ):
10
- print("EMULATED CONTROLNET")
11
- return [image]
12
-
13
- def make_inpainting(positive_prompt,
14
- image,
15
- mask_image,
16
- negative_prompt,
17
- ):
18
- print("EMULATED INPAINTING")
19
- return [image]
20
-
21
- def segment_image(image):
22
- # numpy array of shape (width, height, 3) with ones
23
- print("EMULATED SEGMENTATION")
24
- return np.ones((image.width, image.height, 3))
25
-