Skip to content

Commit

Permalink
restruct html/js and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Jun 1, 2023
1 parent e10d929 commit 251dc34
Show file tree
Hide file tree
Showing 22 changed files with 78 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __pycache__
/webui-user.bat
/webui-user.sh
/html/extensions.json
/javascript/themes.json
/html/themes.json
node_modules
pnpm-lock.yaml
package-lock.json
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- redesign action box to be uniform accross all themes
- add pause option next to stop/skip
- redesign progress bar
- enable more image formats
note: not all are understood by browser so previews and images may appear as blank
unless you have some browser extensions that can handle them
but they do get stored correctly. and cant beat raw quality of 32-bit tiff or psd :)

## Update for 05/30/2023

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Below is partial list of all available parameters, run `webui --help` for the fu
--upgrade Upgrade main repository to latest version, default: False
--safe Run in safe mode with no user extensions

<br>![screenshot](javascript/black-orange.jpg)<br>
<br>![screenshot](html/black-orange.jpg)<br>

## Notes

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
15 changes: 9 additions & 6 deletions installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,16 @@ def update(folder):
# clone git repository
def clone(url, folder, commithash=None):
if os.path.exists(folder):
if commithash is None:
return
current_hash = git('rev-parse HEAD', folder).strip()
if current_hash != commithash:
git('fetch', folder)
git(f'checkout {commithash}', folder)
if args.skip_update:
return
if commithash is None:
update(folder)
else:
current_hash = git('rev-parse HEAD', folder).strip()
if current_hash != commithash:
git('fetch', folder)
git(f'checkout {commithash}', folder)
return
else:
log.info(f'Cloning repository: {url}')
git(f'clone "{url}" "{folder}"')
Expand Down
106 changes: 25 additions & 81 deletions javascript/hints.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
13 changes: 0 additions & 13 deletions javascript/package.json

This file was deleted.

20 changes: 20 additions & 0 deletions javascript/set-hints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
onUiUpdate(() => {
gradioApp().querySelectorAll('span, button, select, p').forEach((span) => {
tooltip = titles[span.textContent];
if (!tooltip) tooltip = titles[span.value];
if (!tooltip) {
for (const c of span.classList) {
if (c in titles) {
tooltip = titles[c];
break;
}
}
}
if (tooltip) span.title = tooltip;
});

gradioApp().querySelectorAll('select').forEach((select) => {
if (select.onchange != null) return;
select.onchange = () => select.title = titles[select.value] || '';
});
});
6 changes: 3 additions & 3 deletions javascript/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ function preview_theme() {
if (name === 'black-orange' || name.startsWith('gradio/')) {
const el = document.getElementById('theme-preview') || create_theme_element();
el.style.display = el.style.display === 'block' ? 'none' : 'block';
if (name === 'black-orange') el.src = '/file=javascript/black-orange.jpg';
else el.src = `/file=javascript/${name.replace('/', '-')}.jpg`;
if (name === 'black-orange') el.src = '/file=html/black-orange.jpg';
else el.src = `/file=html/${name.replace('/', '-')}.jpg`;
} else {
fetch('/file=javascript/themes.json')
fetch('/file=html/themes.json')
.then((r) => r.json())
.then((themes) => {
const theme = themes.find((t) => t.id === name);
Expand Down
1 change: 0 additions & 1 deletion modules/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def save_image(image, fn, ext):

def encode_pil_to_base64(image):
# TODO jpeg
print('HERE1', vars(image))
with io.BytesIO() as output_bytes:
save_image(image, output_bytes, shared.opts.samples_format)
bytes_data = output_bytes.getvalue()
Expand Down
4 changes: 2 additions & 2 deletions modules/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def wrap(drawing, text, font, line_length):

def get_font(fontsize):
try:
return ImageFont.truetype(shared.opts.font or 'javascript/roboto.ttf', fontsize)
return ImageFont.truetype(shared.opts.font or 'html/roboto.ttf', fontsize)
except Exception:
return ImageFont.truetype('javascript/roboto.ttf', fontsize)
return ImageFont.truetype('hmtl/roboto.ttf', fontsize)

def draw_texts(drawing, draw_x, draw_y, lines, initial_fnt, initial_fontsize):
for _i, line in enumerate(lines):
Expand Down
1 change: 0 additions & 1 deletion modules/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@ def save_intermediate(image, index):
else:
img2img_sampler_name = 'UniPC'
self.sampler = sd_samplers.create_sampler(img2img_sampler_name, self.sd_model)
print('HERE', force_latent_upscaler, img2img_sampler_name, self.sampler)
samples = samples[:, :, self.truncate_y//2:samples.shape[2]-(self.truncate_y+1)//2, self.truncate_x//2:samples.shape[3]-(self.truncate_x+1)//2]
noise = create_random_tensors(samples.shape[1:], seeds=seeds, subseeds=subseeds, subseed_strength=subseed_strength, p=self)
# GC now before running the next img2img to prevent running out of memory
Expand Down
Loading

0 comments on commit 251dc34

Please sign in to comment.