Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abormal behavior #73

Open
dentistfrankchen opened this issue May 1, 2023 · 2 comments
Open

abormal behavior #73

dentistfrankchen opened this issue May 1, 2023 · 2 comments

Comments

@dentistfrankchen
Copy link

I followed and copied the code on your main page, however it did not behave normally:
ValueError Traceback (most recent call last)
Cell In[5], line 4
1 from stable_diffusion_tf.stable_diffusion import StableDiffusion
2 from PIL import Image
----> 4 generator = StableDiffusion()

File ~/anaconda3/envs/art_intel/lib/python3.9/site-packages/stable_diffusion_tf/stable_diffusion.py:24, in StableDiffusion.init(self, img_height, img_width, jit_compile, download_weights)
21 self.img_width = img_width
22 self.tokenizer = SimpleTokenizer()
---> 24 text_encoder, diffusion_model, decoder, encoder = get_models(img_height, img_width, download_weights=download_weights)
25 self.text_encoder = text_encoder
26 self.diffusion_model = diffusion_model

File ~/anaconda3/envs/art_intel/lib/python3.9/site-packages/stable_diffusion_tf/stable_diffusion.py:238, in get_models(img_height, img_width, download_weights)
235 latent = keras.layers.Input((n_h, n_w, 4))
236 unet = UNetModel()
237 diffusion_model = keras.models.Model(
--> 238 [latent, t_emb, context], unet([latent, t_emb, context])
239 )
241 # Create decoder
242 latent = keras.layers.Input((n_h, n_w, 4))

File ~/anaconda3/envs/art_intel/lib/python3.9/site-packages/keras/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb

File /tmp/autograph_generated_file2lo7vt15.py:84, in outer_factory..inner_factory..tf__call(self, inputs)
82 layer = ag
.Undefined('layer')
83 b = ag__.Undefined('b')
---> 84 ag__.for_stmt(ag__.ld(self).input_blocks, None, loop_body_1, get_state_3, set_state_3, ('x',), {'iterate_names': 'b'})
86 def get_state_4():
87 return (x,)

File /tmp/autograph_generated_file2lo7vt15.py:80, in outer_factory..inner_factory..tf__call..loop_body_1(itr_1)
78 layer = itr
79 x = ag
.converted_call(ag__.ld(apply), (ag__.ld(x), ag__.ld(layer)), None, fscope)
---> 80 ag__.for_stmt(ag__.ld(b), None, loop_body, get_state_2, set_state_2, ('x',), {'iterate_names': 'layer'})
81 ag__.converted_call(ag__.ld(saved_inputs).append, (ag__.ld(x),), None, fscope)

File /tmp/autograph_generated_file2lo7vt15.py:79, in outer_factory..inner_factory..tf__call..loop_body_1..loop_body(itr)
77 nonlocal x
78 layer = itr
---> 79 x = ag
.converted_call(ag__.ld(apply), (ag__.ld(x), ag__.ld(layer)), None, fscope)

File /tmp/autograph_generated_file2lo7vt15.py:48, in outer_factory..inner_factory..tf__call..apply(x, layer)
46 x = ag
.converted_call(ag__.ld(layer), (ag__.ld(x),), None, fscope_1)
47 ag__.if_stmt(ag__.converted_call(ag__.ld(isinstance), (ag__.ld(layer), ag__.ld(SpatialTransformer)), None, fscope_1), if_body, else_body, get_state, set_state, ('x',), 1)
---> 48 ag__.if_stmt(ag__.converted_call(ag__.ld(isinstance), (ag__.ld(layer), ag__.ld(ResBlock)), None, fscope_1), if_body_1, else_body_1, get_state_1, set_state_1, ('x',), 1)
49 try:
50 do_return_1 = True

File /tmp/autograph_generated_file2lo7vt15.py:28, in outer_factory..inner_factory..tf__call..apply..if_body_1()
26 def if_body_1():
27 nonlocal x
---> 28 x = ag
.converted_call(ag__.ld(layer), ([ag__.ld(x), ag__.ld(emb)],), None, fscope_1)

File /tmp/autograph_generated_filem_kzpxnn.py:11, in outer_factory..inner_factory..tf__call(self, inputs)
9 retval
= ag
_.UndefinedReturnValue()
10 (x, emb) = ag__.ld(inputs)
---> 11 h = ag__.converted_call(ag__.ld(apply_seq), (ag__.ld(x), ag__.ld(self).in_layers), None, fscope)
12 emb_out = ag__.converted_call(ag__.ld(apply_seq), (ag__.ld(emb), ag__.ld(self).emb_layers), None, fscope)
13 h = ag__.ld(h) + ag__.ld(emb_out)[:, None, None]

File /tmp/autograph_generated_file612zmgqy.py:23, in outer_factory..inner_factory..tf__apply_seq(x, layers)
21 x = ag
.converted_call(ag__.ld(l), (ag__.ld(x),), None, fscope)
22 l = ag__.Undefined('l')
---> 23 ag__.for_stmt(ag__.ld(layers), None, loop_body, get_state, set_state, ('x',), {'iterate_names': 'l'})
24 try:
25 do_return = True

File /tmp/autograph_generated_file612zmgqy.py:21, in outer_factory..inner_factory..tf__apply_seq..loop_body(itr)
19 nonlocal x
20 l = itr
---> 21 x = ag
.converted_call(ag__.ld(l), (ag__.ld(x),), None, fscope)

File ~/anaconda3/envs/art_intel/lib/python3.9/site-packages/tensorflow_addons/layers/normalizations.py:110, in GroupNormalization.build(self, input_shape)
108 self._check_if_input_shape_is_none(input_shape)
109 self._set_number_of_groups_for_instance_norm(input_shape)
--> 110 self._check_size_of_dimensions(input_shape)
111 self._create_input_spec(input_shape)
113 self._add_gamma_weight(input_shape)

File ~/anaconda3/envs/art_intel/lib/python3.9/site-packages/tensorflow_addons/layers/normalizations.py:227, in GroupNormalization._check_size_of_dimensions(self, input_shape)
225 dim = input_shape[self.axis]
226 if dim < self.groups:
--> 227 raise ValueError(
228 "Number of groups (" + str(self.groups) + ") cannot be "
229 "more than the number of channels (" + str(dim) + ")."
230 )
232 if dim % self.groups != 0:
233 raise ValueError(
234 "Number of groups (" + str(self.groups) + ") must be a "
235 "multiple of the number of channels (" + str(dim) + ")."
236 )

ValueError: Exception encountered when calling layer "u_net_model_1" (type UNetModel).

in user code:

File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/stable_diffusion_tf/diffusion_model.py", line 199, in apply  *
    x = layer([x, emb])
File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler  **
    raise e.with_traceback(filtered_tb) from None
File "/tmp/__autograph_generated_filem_kzpxnn.py", line 11, in tf__call
    h = ag__.converted_call(ag__.ld(apply_seq), (ag__.ld(x), ag__.ld(self).in_layers), None, fscope)
File "/tmp/__autograph_generated_file612zmgqy.py", line 23, in tf__apply_seq

ag__.for_stmt(ag__.ld(layers), None, loop_body, get_state, set_state, ('x',), {'iterate_names': 'l'})
File "/tmp/autograph_generated_file612zmgqy.py", line 21, in loop_body
x = ag
.converted_call(ag__.ld(l), (ag__.ld(x),), None, fscope)
File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/tensorflow_addons/layers/normalizations.py", line 110, in build
self._check_size_of_dimensions(input_shape)
File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/tensorflow_addons/layers/normalizations.py", line 227, in _check_size_of_dimensions
raise ValueError(

ValueError: Exception encountered when calling layer "res_block_22" "                 f"(type ResBlock).

in user code:

    File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/stable_diffusion_tf/diffusion_model.py", line 31, in call  *
        h = apply_seq(x, self.in_layers)
    File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/stable_diffusion_tf/layers.py", line 41, in apply_seq  *
        x = l(x)
    File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler  **
        raise e.with_traceback(filtered_tb) from None
    File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/tensorflow_addons/layers/normalizations.py", line 110, in build
        self._check_size_of_dimensions(input_shape)
    File "/home/ec2-user/anaconda3/envs/art_intel/lib/python3.9/site-packages/tensorflow_addons/layers/normalizations.py", line 227, in _check_size_of_dimensions
        raise ValueError(

    ValueError: Number of groups (32) cannot be more than the number of channels (4).


Call arguments received by layer "res_block_22" "                 f"(type ResBlock):
  • inputs=['tf.Tensor(shape=(None, 320, 125, 4), dtype=float32)', 'tf.Tensor(shape=(None, 1280), dtype=float32)']

Call arguments received by layer "u_net_model_1" (type UNetModel):
• inputs=['tf.Tensor(shape=(None, 125, 125, 4), dtype=float32)', 'tf.Tensor(shape=(None, 320), dtype=float32)', 'tf.Tensor(shape=(None, 77, 768), dtype=float32)']

@WSINTRA
Copy link

WSINTRA commented May 1, 2023 via email

@dentistfrankchen
Copy link
Author

dentistfrankchen commented May 1, 2023

@WSINTRA
A 512x512 image.
I have already tried the code on the main page and added img_height=..., img_width=..., but that did not work. I still got the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants