Spaces:
Build error
Build error
brayden-gg
commited on
Commit
·
3e4d521
1
Parent(s):
a21775a
set max randomness to 0 for writer/char blends
Browse files- .gitignore +1 -0
- app.py +4 -12
.gitignore
CHANGED
@@ -5,6 +5,7 @@ data/writers/*
|
|
5 |
*.gif
|
6 |
results/
|
7 |
samples/
|
|
|
8 |
|
9 |
!/data/writers/5
|
10 |
!/data/writers/14
|
|
|
5 |
*.gif
|
6 |
results/
|
7 |
samples/
|
8 |
+
__pycache__/
|
9 |
|
10 |
!/data/writers/5
|
11 |
!/data/writers/14
|
app.py
CHANGED
@@ -15,10 +15,7 @@ num_samples = 10
|
|
15 |
net = SynthesisNetwork(weight_dim=256, num_layers=3).to(device)
|
16 |
|
17 |
if not torch.cuda.is_available():
|
18 |
-
|
19 |
-
net.load_state_dict(torch.load('./model/250000.pt', map_location=torch.device(device))["model_state_dict"])
|
20 |
-
except:
|
21 |
-
net.load_state_dict(torch.load('./model/250000.pt', map_location=torch.device(device)))
|
22 |
|
23 |
|
24 |
dl = DataLoader(num_writer=1, num_samples=10, divider=5.0, datadir='./data/writers')
|
@@ -39,7 +36,8 @@ def interpolate_writers(target_word, weight):
|
|
39 |
return image
|
40 |
|
41 |
def choose_blend_writers(writer1, writer2):
|
42 |
-
|
|
|
43 |
all_loaded_data.clear()
|
44 |
for writer_id in [id1, id2]:
|
45 |
loaded_data = dl.next_batch(TYPE='TRAIN', uid=writer_id, tids=list(range(num_samples)))
|
@@ -54,16 +52,10 @@ def choose_writer(writ, c1, c2, c3, c4, val):
|
|
54 |
all_loaded_data.append(loaded_data)
|
55 |
return char_grid(c1, c2, c3, c4, val)
|
56 |
'''
|
57 |
-
# for character grrid
|
58 |
-
def choose_grid_chars(c1, c2, c3, c4):
|
59 |
-
return gr.Button.update(value=f"Blend {c1}, {c2}, {c3}, and {c4}!")
|
60 |
-
|
61 |
-
def char_grid(c1, c2, c3, c4):
|
62 |
-
image = convenience.sample_character_grid([c1, c2, c3, c4], 5, net, [default_loaded_data], device).convert("RGB")
|
63 |
-
return image
|
64 |
|
65 |
# for character blend
|
66 |
def interpolate_chars(c1, c2, weight):
|
|
|
67 |
image = convenience.sample_blended_chars([1 - weight, weight], [c1, c2], net, [default_loaded_data], device).convert("RGB")
|
68 |
return image
|
69 |
|
|
|
15 |
net = SynthesisNetwork(weight_dim=256, num_layers=3).to(device)
|
16 |
|
17 |
if not torch.cuda.is_available():
|
18 |
+
net.load_state_dict(torch.load('./model/250000.pt', map_location=torch.device(device))["model_state_dict"])
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
dl = DataLoader(num_writer=1, num_samples=10, divider=5.0, datadir='./data/writers')
|
|
|
36 |
return image
|
37 |
|
38 |
def choose_blend_writers(writer1, writer2):
|
39 |
+
net.clamp_mdn = 0
|
40 |
+
id1, id2 = int(writer1.split(" ")[1]), int(writer2.split(" ")[1])
|
41 |
all_loaded_data.clear()
|
42 |
for writer_id in [id1, id2]:
|
43 |
loaded_data = dl.next_batch(TYPE='TRAIN', uid=writer_id, tids=list(range(num_samples)))
|
|
|
52 |
all_loaded_data.append(loaded_data)
|
53 |
return char_grid(c1, c2, c3, c4, val)
|
54 |
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# for character blend
|
57 |
def interpolate_chars(c1, c2, weight):
|
58 |
+
net.clamp_mdn = 0
|
59 |
image = convenience.sample_blended_chars([1 - weight, weight], [c1, c2], net, [default_loaded_data], device).convert("RGB")
|
60 |
return image
|
61 |
|