gutris1 commited on
Commit
6972b49
·
verified ·
1 Parent(s): 5a47eb0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ js = """
4
+ () => {
5
+ document.documentElement.style.background = document.body.classList.contains('dark') ? '#0b0f19' : '#fff';
6
+ document.body.style.display = 'none';
7
+
8
+ //const footer = document.querySelector('body > gradio-app footer');
9
+ //footer.replaceChildren();
10
+
11
+ const url = [
12
+ 'https://cdn.jsdelivr.net/gh/mattiasw/ExifReader@29524b5/dist/exif-reader.js',
13
+ 'https://cdn.jsdelivr.net/gh/gutris1/sd-image-parser@d29cd9c/javascript/image-parser.js',
14
+ 'https://cdn.jsdelivr.net/gh/gutris1/image-info-space@b020eb6/script.js'
15
+ ];
16
+
17
+ url.forEach(src => {
18
+ const script = document.createElement('script');
19
+ script.type = 'text/javascript';
20
+ script.async = true;
21
+ script.src = src;
22
+ document.head.append(script);
23
+ });
24
+
25
+ const css = document.createElement('link');
26
+ css.rel = 'stylesheet';
27
+ css.href = `https://cdn.jsdelivr.net/gh/gutris1/image-info-space@71b8571/style.css`;
28
+ document.head.append(css);
29
+
30
+ const input = document.querySelector('#SDImageInfo-Image input');
31
+ input.parentNode.insertBefore(Object.assign(document.createElement('div'), { id: 'SDImageInfo-Image-Frame' }), input);
32
+ document.body.style.display = '';
33
+ }
34
+ """
35
+
36
+ with gr.Blocks(analytics_enabled=False, theme='NoCrypt/miku') as app:
37
+ with gr.Column(elem_id='SDImageInfo-Column'):
38
+ image = gr.Image(elem_id='SDImageInfo-Image', type='pil', show_label=False)
39
+ image.change(fn=None, _js='() => { SDImageInfoParser(); }')
40
+
41
+ with gr.Column(elem_id='SDImageInfo-OutputPanel'):
42
+ gr.Textbox(elem_id='SDImageInfo-Geninfo', visible=False)
43
+ gr.HTML(elem_id='SDImageInfo-HTML')
44
+
45
+ app.load(None, _js=js)
46
+
47
+ app.launch()