Skip to content

Commit 2ecd85f

Browse files
authored
Merge branch 'divamgupta:master' into add-notification-sound
2 parents c07239c + ad351b3 commit 2ecd85f

File tree

10 files changed

+28
-15
lines changed

10 files changed

+28
-15
lines changed

backends/model_converter/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ optimized_stable_diffusion/
33

44
convert_sd_model_bin
55
./convert_sd_model_bin
6+
convert_sd_model_bin/
7+
./convert_sd_model_bin/
68

79
HF_weights/
810
outputs/

backends/model_converter/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pyinstaller convert_model.py --onefile --noconfirm --clean
1+
pyinstaller convert_model.py --noconfirm --clean

backends/model_converter/convert_model.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@
3333
extra_keys = ['temb_coefficients_fp32' , 'causal_mask' , 'aux_output_conv.weight' , 'aux_output_conv.bias', 'alphas_cumprod']
3434

3535
for k in torch_weights['state_dict']:
36-
if k not in extra_keys:
37-
assert k in SD_SHAPES , k
36+
if k not in SD_SHAPES:
37+
continue
3838
np_arr = torch_weights['state_dict'][k]
3939
key_bytes = np_arr.tobytes()
4040
shape = list(np_arr.shape)
4141
if k not in extra_keys:
42-
assert tuple(shape) == SD_SHAPES[k], (k , shape , SD_SHAPES[k] )
42+
assert tuple(shape) == SD_SHAPES[k], ( "shape mismatch at" , k , shape , SD_SHAPES[k] )
4343
dtype = str(np_arr.dtype)
44+
if dtype == 'int64':
45+
np_arr = np_arr.astype('float32')
46+
dtype = 'float32'
4447
assert dtype in ['float16' , 'float32']
4548
e = s + len(key_bytes)
4649
out_file.write(key_bytes)

backends/model_converter/fake_torch.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pickle
22
import numpy as np
33
import math
4+
import zipfile
45

56
def prod(x):
67
return math.prod(x)
@@ -52,13 +53,17 @@ def persistent_load(self, pid):
5253
return MyPickle(fb0).load(), key_prelookup
5354

5455
def fake_torch_load_zipped(fb0, load_weights=True):
55-
import zipfile
56+
5657
with zipfile.ZipFile(fb0, 'r') as myzip:
57-
with myzip.open('archive/data.pkl') as myfile:
58+
folder_name = [a for a in myzip.namelist() if a.endswith("/data.pkl")]
59+
if len(folder_name)== 0:
60+
raise ValueError("Looke like the checkpoints file is in the wrong format")
61+
folder_name = folder_name[0].replace("/data.pkl" , "").replace("\\data.pkl" , "")
62+
with myzip.open(folder_name+'/data.pkl') as myfile:
5863
ret = my_unpickle(myfile)
5964
if load_weights:
6065
for k,v in ret[1].items():
61-
with myzip.open(f'archive/data/{k}') as myfile:
66+
with myzip.open(folder_name + f'/data/{k}') as myfile:
6267
if v[2].dtype == "object":
6368
print(f"issue assigning object on {k}")
6469
continue

backends/stable_diffusion_tf/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ cp stable_diffusion_tf/clip_tokenizer/bpe_simple_vocab_16e6.txt.gz ./dist/diffus
33

44
cp -r ../realesrgan_ncnn/models ./dist/diffusionbee_backend/models
55
cp ../realesrgan_ncnn/realesrgan_ncnn_macos ./dist/diffusionbee_backend/realesrgan_ncnn_macos
6-
cp ../model_converter/convert_sd_model_bin ./dist/diffusionbee_backend/convert_model
6+
cp -r ../model_converter/convert_sd_model_bin/m1 ./dist/diffusionbee_backend/convert_model

electron_app/src/background.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ protocol.registerSchemesAsPrivileged([
2626
])
2727

2828

29-
// import {menu_template} from "./menu_template"
30-
// Menu.setApplicationMenu(Menu.buildFromTemplate(menu_template))
29+
import {menu_template} from "./menu_template"
30+
Menu.setApplicationMenu(Menu.buildFromTemplate(menu_template))
3131

3232
start_bridge();
3333

electron_app/src/components/Outpainting.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
v-bind:class="{ 'disabled' : !stable_diffusion.is_input_avail}"
2121
:rows="2">
2222
</textarea>
23+
24+
25+
2326

2427
<div v-if="stable_diffusion.is_input_avail" style="margin-top: 20px">
2528

@@ -43,7 +46,7 @@
4346
<LoaderModal :loading_percentage="done_percentage" loading_title="Generating" :loading_desc="stable_diffusion.generation_state_msg"></LoaderModal>
4447
</div>
4548

46-
<p style="opacity:0.5; zoom:0.8"> Please describe image you want to draw in the box. </p>
49+
<p style="opacity:0.5; zoom:0.8; float:left; max-width: calc(100vw - 200px); margin-bottom: 0; "> Please describe image you want to draw in the box. </p>
4750

4851
</div>
4952
</template>
@@ -117,7 +120,7 @@ export default {
117120
methods: {
118121
init_state(){
119122
let that = this;
120-
this.stage_h = this.stage_w / (window.innerWidth / ( window.innerHeight - 210 ));
123+
this.stage_h = this.stage_w / (window.innerWidth / ( window.innerHeight - 230 ));
121124
122125
this.prompt = ""
123126

electron_app/src/components_bare/SDOptionsDropdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export default {
297297
SetGuidenceScale(e) {
298298
var value = (e.target.value - e.target.min) / (e.target.max - e.target.min) * 100
299299
e.target.style.background = 'linear-gradient(to right, var(--slider-progress) 0%, var(--slider-progress) ' + value + '%, var(--slider-progress_end) ' + value + '%, var(--slider-progress_end) 100%)'
300-
// this.options_model_values.guidence_scale = Number(e.target.value)
300+
this.options_model_values.guidence_scale = Number(e.target.value)
301301
}
302302
},
303303
}

electron_app/src/native_functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ function add_custom_pytorch_models(pytorch_model_path, model_name, cb ){
463463
}
464464

465465
let out_path = path.join(homedir , ".diffusionbee" , "custom_models" , model_name+".tdict" );
466-
let bin_path = process.env.CONVERT_MODEL_BIN || path.join(path.dirname(__dirname), 'core' , 'convert_model' );
466+
let bin_path = process.env.CONVERT_MODEL_BIN || path.join(path.dirname(__dirname), 'core' , 'convert_model' , 'convert_model' );
467467

468468

469469
let proc = require('child_process').spawn( bin_path , [pytorch_model_path , out_path ]);

electron_app/vue.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
"target": {
3232
"target": "dmg",
3333
"arch": [
34-
'arm64' , 'x64'
34+
process.env.BUILD_ARCH //'arm64' , 'x64'
3535
]
3636
}
3737
},

0 commit comments

Comments
 (0)