Spaces:
Runtime error
Runtime error
Reduce output png size, clean up template file, clear \r chars from text output
Browse files- app.py +2 -2
- monsterMakerTemplate.html +0 -34
app.py
CHANGED
|
@@ -103,7 +103,7 @@ def gen_monster_text(name):
|
|
| 103 |
inp = tensor(prompt_ids)[None]
|
| 104 |
preds = learner.model.generate(inp, max_length=1024, num_beams=5, temperature=1.5, do_sample=True)
|
| 105 |
result = tokenizer.decode(preds[0].cpu().numpy())
|
| 106 |
-
result = result.split('###')[0].replace(r'\r\n', '\n')
|
| 107 |
print(f'GENERATING MONSTER COMPLETE')
|
| 108 |
print(result)
|
| 109 |
return result
|
|
@@ -261,7 +261,7 @@ hti = Html2Image(output_path='rendered_cards')
|
|
| 261 |
|
| 262 |
def html_to_png(html):
|
| 263 |
print('CONVERTING HTML CARD TO PNG IMAGE')
|
| 264 |
-
paths = hti.screenshot(html_str=html, css_file="monstermaker.css", save_as="test.png")
|
| 265 |
path = paths[0]
|
| 266 |
print('OPENING IMAGE FROM FILE')
|
| 267 |
img = Image.open(path).convert("RGB")
|
|
|
|
| 103 |
inp = tensor(prompt_ids)[None]
|
| 104 |
preds = learner.model.generate(inp, max_length=1024, num_beams=5, temperature=1.5, do_sample=True)
|
| 105 |
result = tokenizer.decode(preds[0].cpu().numpy())
|
| 106 |
+
result = result.split('###')[0].replace(r'\r\n', '\n').replace('\r', '').replace(r'\r', '')
|
| 107 |
print(f'GENERATING MONSTER COMPLETE')
|
| 108 |
print(result)
|
| 109 |
return result
|
|
|
|
| 261 |
|
| 262 |
def html_to_png(html):
|
| 263 |
print('CONVERTING HTML CARD TO PNG IMAGE')
|
| 264 |
+
paths = hti.screenshot(html_str=html, css_file="monstermaker.css", save_as="test.png", size=(400, 1440))
|
| 265 |
path = paths[0]
|
| 266 |
print('OPENING IMAGE FROM FILE')
|
| 267 |
img = Image.open(path).convert("RGB")
|
monsterMakerTemplate.html
CHANGED
|
@@ -30,9 +30,6 @@
|
|
| 30 |
<h4>{name}</h4>
|
| 31 |
<p class="monster-description">{monster_type}</p>
|
| 32 |
</div>
|
| 33 |
-
<!-- <div class="monster-quickstart">-->
|
| 34 |
-
<!-- <p>Level 1 Striker<br> Standard <span class="solo-only">vs 4 </span>(50 XP)</p>-->
|
| 35 |
-
<!-- </div>-->
|
| 36 |
</div>
|
| 37 |
<hr>
|
| 38 |
<ul>
|
|
@@ -139,44 +136,13 @@
|
|
| 139 |
</p>
|
| 140 |
</li>
|
| 141 |
</ul>
|
| 142 |
-
<!-- <hr>-->
|
| 143 |
-
<!-- <ul class="quickstart-helpers">-->
|
| 144 |
-
<!-- <li>-->
|
| 145 |
-
<!-- <p>-->
|
| 146 |
-
<!-- <span class="label">Attacks</span>-->
|
| 147 |
-
<!-- <span>+5 to hit. <i>Hit:</i> 3 damage</span>-->
|
| 148 |
-
<!-- </p>-->
|
| 149 |
-
<!-- </li>-->
|
| 150 |
-
<!-- <li>-->
|
| 151 |
-
<!-- <p>-->
|
| 152 |
-
<!-- <span class="label">Attack DCs</span>-->
|
| 153 |
-
<!-- <span>Primary DC 13, Secondary DC 10</span>-->
|
| 154 |
-
<!-- </p>-->
|
| 155 |
-
<!-- </li>-->
|
| 156 |
-
<!-- </ul>-->
|
| 157 |
<hr>
|
| 158 |
<h5 class="h5-traits">Traits</h5>
|
| 159 |
<div class="h5-border"></div>
|
| 160 |
{passives}
|
| 161 |
-
<!-- <div class="monster-trait">-->
|
| 162 |
-
<!-- <p><span class="name">(Striker) Savage Assault.</span> <span class="detail">Once per turn, add your-->
|
| 163 |
-
<!-- level in extra damage to an attack.</span></p>-->
|
| 164 |
-
<!-- </div>-->
|
| 165 |
-
<!-- <div class="monster-trait">-->
|
| 166 |
-
<!-- <p><span class="name">Shifty.</span> <span class="detail">You can <i>Disengage</i> as a bonus-->
|
| 167 |
-
<!-- action.</span></p>-->
|
| 168 |
-
<!-- </div>-->
|
| 169 |
<h5>Actions</h5>
|
| 170 |
<div class="h5-border"></div>
|
| 171 |
{actions}
|
| 172 |
-
<!-- <div class="monster-action">-->
|
| 173 |
-
<!-- <p><span class="name">Slash.</span> <span class="detail"><i>Melee Weapon Attack:</i> +5 vs AC.-->
|
| 174 |
-
<!-- <i>Hit:</i> 3 (1d4 + 1) slashing damage.</span></p>-->
|
| 175 |
-
<!-- </div>-->
|
| 176 |
-
<!-- <div class="monster-action">-->
|
| 177 |
-
<!-- <p><span class="name">Knockback.</span> <span class="detail"><i>Melee Weapon Attack:</i> DC 13 vs-->
|
| 178 |
-
<!-- Strength. <i>Hit:</i> the target is pushed up to 10 ft away.</span></p>-->
|
| 179 |
-
<!-- </div>-->
|
| 180 |
<h5 class="h5-notes">Notes</h5>
|
| 181 |
<div class="h5-border"></div>
|
| 182 |
<div class="monster-notes">
|
|
|
|
| 30 |
<h4>{name}</h4>
|
| 31 |
<p class="monster-description">{monster_type}</p>
|
| 32 |
</div>
|
|
|
|
|
|
|
|
|
|
| 33 |
</div>
|
| 34 |
<hr>
|
| 35 |
<ul>
|
|
|
|
| 136 |
</p>
|
| 137 |
</li>
|
| 138 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
<hr>
|
| 140 |
<h5 class="h5-traits">Traits</h5>
|
| 141 |
<div class="h5-border"></div>
|
| 142 |
{passives}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
<h5>Actions</h5>
|
| 144 |
<div class="h5-border"></div>
|
| 145 |
{actions}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
<h5 class="h5-notes">Notes</h5>
|
| 147 |
<div class="h5-border"></div>
|
| 148 |
<div class="monster-notes">
|