stonapse64 commited on
Commit
da29f14
1 Parent(s): cc35dba

Working on...

Browse files
Files changed (5) hide show
  1. app.py +84 -25
  2. app_sic.py +21 -0
  3. resources.py +68 -12
  4. scratch.py +76 -0
  5. scratch_2.py +92 -0
app.py CHANGED
@@ -1,35 +1,94 @@
1
  import gradio as gr
 
2
  from resources import *
3
 
4
- gr.set_static_paths(paths=["images/"])
 
5
 
6
- bellamy_bowie_description = """<img src="static/Siemens_logo.png" alt="My Image"/>"""
7
- urly_murly_simmy_description = """<img src="static/Siemens_logo.png" alt="My Image" style="float: left; margin-right: 10px;" />"""
8
- # ellis_cappy_description = """
9
- # <table border="0">
10
- # <tr>
11
- # <td>
12
- # <h1>Meet Ellis Cappy: The Quacktastic Caption Creator!</h1><br>
13
- # Why rely on lazy humans when you can have an AI duck with flair? 🤖🦆<br><br>
14
- # Ellis Cappy is on a mission to turn mundane visuals into quackingly good content and is the feathered genius behind our image captions! 📸🌟<br><br>
15
- # Our superior AI duck waddles through pixelated landscapes, its webbed feet tapping out witty one-liners faster than a duckling chasing breadcrumbs. 📝💨<br><br><br>
16
- # </td>
17
- # <td rowspan=3><img src="https://images.nightcafe.studio/jobs/1tLpG6zZANbrgG4ds8wF/1tLpG6zZANbrgG4ds8wF--4--andnn.jpg" width=548/></td>
18
- # </tr>
19
- # </table>
20
- # """
21
 
22
 
23
- def greeting(name):
24
- return f"Hello {name}"
 
25
 
26
 
27
- bellamy_bowie = gr.Interface(greeting, "text", "text", description=bellamy_bowie_description)
28
- urly_murly_simmy = gr.Interface(lambda name: "Hello " + name, "text", "text", description=urly_murly_simmy_description)
29
- ellis_cappy = gr.Interface(lambda name: "Hello " + name, "text", "text", description=ellis_cappy_description)
30
 
31
- aidademo = gr.TabbedInterface(
32
- [bellamy_bowie, urly_murly_simmy, ellis_cappy],
33
- ["Bellamy Bowie", "Urly & Murly Simmy", "Ellis Cappy"], head=bellamy_bowie_description)
34
 
35
- aidademo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
  from resources import *
4
 
5
+ bellamy_bowie_classifier_candidate_labels = ["manager", "engineer", "technician", "politician", "scientist", "student", "journalist", "marketeer", "spokesperson", "other"]
6
+ bellamy_bowie_classifier_candidate_labels_preselection = ["manager", "engineer", "technician", "politician", "scientist", "student", "journalist"]
7
 
8
+ bellamy_bowie_classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
+ def bellamy_bowie_predict(candidate_labels_selected, sequence):
12
+ outputs = bellamy_bowie_classifier(sequence, candidate_labels_selected)
13
+ return dict(zip(outputs['labels'], outputs['scores'])) # Extract labels and scores from the outputs dictionary
14
 
15
 
16
+ def ellis_update(name, age):
17
+ return f"Welcome to Gradio, {name}! Are your really good {age} years old?"
 
18
 
 
 
 
19
 
20
+ # Ellis Cappy stuff
21
+
22
+ ellis_cappy_captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base", max_new_tokens=40)
23
+
24
+
25
+ def ellis_cappy_captionizer(img):
26
+ captions = ellis_cappy_captioner(img)
27
+ return captions[0]["generated_text"]
28
+
29
+
30
+ def marvin_update(origin, name):
31
+ # origin = type(origin)
32
+ return f"Welcome to Gradio, {name}! Are your really from {origin[0]}?"
33
+
34
+
35
+ with gr.Blocks() as demo:
36
+ gr.Markdown("Start typing below and then click **Run** to see the output.")
37
+
38
+ with gr.Tab("Bellamy Bowie"):
39
+ with gr.Row():
40
+ with gr.Column(scale=3):
41
+ gr.HTML(bellamy_bowie_description)
42
+ with gr.Column(scale=1):
43
+ gr.Image(bellamy_bowie_hero, label=None)
44
+ with gr.Row():
45
+ with gr.Column(scale=1):
46
+ bellamy_bowie_checkbox_input = gr.CheckboxGroup(choices=bellamy_bowie_classifier_candidate_labels, value=bellamy_bowie_classifier_candidate_labels_preselection, label="Target personas of your message", info="Recommendation: Don't change the preselection for your first analysis.")
47
+ bellamy_bowie_textbox_input = gr.Textbox(lines=10, placeholder="Your text goes here", label="Write or paste your message to classify")
48
+ with gr.Row():
49
+ bellamy_bowie_clear_button = gr.ClearButton(components=bellamy_bowie_textbox_input, value="Clear")
50
+ bellamy_bowie_submit_button = gr.Button("Submit", variant="primary")
51
+ with gr.Column(scale=1):
52
+ bellamy_bowie_outputs = gr.Label(label="Matching scores by personas")
53
+ gr.HTML(bellamy_bowie_note_quality)
54
+ with gr.Row():
55
+ with gr.Column(scale=1):
56
+ gr.Examples(bellamy_bowie_examples, inputs=[bellamy_bowie_textbox_input])
57
+ gr.HTML(bellamy_bowie_article)
58
+ bellamy_bowie_submit_button.click(fn=bellamy_bowie_predict, inputs=[bellamy_bowie_checkbox_input, bellamy_bowie_textbox_input], outputs=bellamy_bowie_outputs)
59
+
60
+ with gr.Tab("Urly & Murly Simmy"):
61
+ with gr.Row():
62
+ with gr.Column(scale=3):
63
+ gr.HTML(ellis_cappy_description)
64
+ with gr.Column(scale=1):
65
+ gr.Image(ellis_cappy_hero)
66
+ with gr.Row():
67
+ inp_01 = gr.Textbox(placeholder="What is your name?")
68
+ inp_02 = gr.Textbox(placeholder="What is your age?")
69
+ out_0 = gr.Textbox()
70
+ btn_0 = gr.Button("Run")
71
+ btn_0.click(fn=ellis_update, inputs=[inp_01, inp_02], outputs=out_0)
72
+
73
+ with gr.Tab("Ellis Cappy"):
74
+ with gr.Row():
75
+ with gr.Column(scale=3):
76
+ gr.HTML(ellis_cappy_description)
77
+ with gr.Column(scale=1):
78
+ gr.Image(ellis_cappy_hero)
79
+ with gr.Row():
80
+ with gr.Column(scale=1):
81
+ ellis_cappy_image_input = gr.Image(type="pil", label=None)
82
+ ellis_cappy_submit_button = gr.Button("Submit")
83
+ with gr.Column(scale=1):
84
+ ellis_cappy_textbox_output = gr.Textbox(label="Suggested caption", lines=2)
85
+ gr.HTML(ellis_cappy_note_quality)
86
+ with gr.Row():
87
+ with gr.Column(scale=1):
88
+ gr.Examples(ellis_cappy_examples, inputs=[ellis_cappy_image_input])
89
+ gr.HTML(ellis_cappy_article)
90
+
91
+ ellis_cappy_submit_button.click(fn=ellis_cappy_captionizer, inputs=ellis_cappy_image_input,
92
+ outputs=ellis_cappy_textbox_output, api_name="captionizer")
93
+
94
+ demo.launch()
app_sic.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from resources import *
3
+
4
+ bellamy_bowie_description = """<img src="static/Siemens_logo.png" alt="My Image"/>"""
5
+ urly_murly_simmy_description = """<img src="static/Siemens_logo.png" alt="My Image" style="float: left; margin-right: 10px;" />"""
6
+ ellis_cappy_description = """Ellis Cappy description."""
7
+
8
+
9
+ def greeting(name):
10
+ return f"Hello {name}"
11
+
12
+
13
+ bellamy_bowie = gr.Interface(greeting, "text", "text", description=bellamy_bowie_description)
14
+ urly_murly_simmy = gr.Interface(lambda name: "Hello " + name, "text", "text", description=urly_murly_simmy_description)
15
+ ellis_cappy = gr.Interface(lambda name: "Hello " + name, "text", "text", description=ellis_cappy_description)
16
+
17
+ aidademo = gr.TabbedInterface(
18
+ [bellamy_bowie, urly_murly_simmy, ellis_cappy],
19
+ ["Bellamy Bowie", "Urly & Murly Simmy", "Ellis Cappy"], head=bellamy_bowie_description)
20
+
21
+ aidademo.launch()
resources.py CHANGED
@@ -1,13 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ellis_cappy_description = """
2
- <table border="0">
3
- <tr>
4
- <td>
5
- <h1>Meet Ellis Cappy: The Quacktastic Caption Creator!</h1><br>
6
- Why rely on lazy humans when you can have an AI duck with flair? 🤖🦆<br><br>
7
- Ellis Cappy is on a mission to turn mundane visuals into quackingly good content and is the feathered genius behind our image captions! 📸🌟<br><br>
8
- Our superior AI duck waddles through pixelated landscapes, its webbed feet tapping out witty one-liners faster than a duckling chasing breadcrumbs. 📝💨<br><br><br>
9
- </td>
10
- <td rowspan=3><img src="https://images.nightcafe.studio/jobs/1tLpG6zZANbrgG4ds8wF/1tLpG6zZANbrgG4ds8wF--4--andnn.jpg" width=548/></td>
11
- </tr>
12
- </table>
13
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A file containing text resources, asset links and examples for the aida demo apps.
2
+
3
+ # Bellamy Bowie
4
+
5
+ bellamy_bowie_description = """
6
+ <h1>Let Bellamy Bowie sense the target personas of your messages!</h1><br>
7
+ Step in and meet the one and only, the enigmatic Bellamy Bowie - a digital dynamo with a flair for the fabulous and a penchant for personality profiling! <br><br>
8
+ Bellamy doesn't just read tea leaves; She reads targets! Whether it's a tech-savvy millennial or a buttoned-up executive
9
+ , Bellamy Bowie sniffs out their digital footprints faster than a caffeinated squirrel on Wi-Fi steroids.<br><br><br>
10
+ """
11
+
12
+ bellamy_bowie_hero = "https://images.nightcafe.studio/jobs/Vu8L5flHfXRI2WQ0mifU/Vu8L5flHfXRI2WQ0mifU--1--pc71j.jpg"
13
+
14
+ bellamy_bowie_examples = [
15
+ ["Smart Infrastructure: Technology to transform the everyday. Demographic change, urbanization, glocalization, environmental change, resource efficiency, and digitalization are presenting new challenges and opportunities. Smart Infrastructure addresses these topics by combining the real and the digital worlds. Our technology transforms infrastructure at speed and scale, enabling collaborative ecosystems to accelerate our customers’ digital journey. To deliver on infrastructure transition at speed and scale, we put digitalization and technology at the heart of our approach and empower our customers to scale sustainable impact. Together, we create energy efficiency – through CO2 transparency, renewable integration, and electrification. We help customers to improve asset performance, availability, and reliability, through resource-efficient and circular products which optimize production and supply chains throughout their entire lifecycle. We enable them to offer safe and comfortable environments that understand and adapt to the needs of their users."],
16
+ ["Hacking for Siemens: After a successful opening hackathon at the Siemens headquarters in Munich, the wait for a second one did not take long. The global event in Prague included an even larger audience and exciting use cases with a common goal: solving real-life business problems across Siemens with ecosystems and co-creation."],
17
+ ["Power-system automation is the act of automatically controlling the power system via instrumentation and control devices. Substation automation refers to using data from Intelligent electronic devices (IED), control and automation capabilities within the substation, and control commands from remote users to control power-system devices.Since full substation automation relies on substation integration, the terms are often used interchangeably. Power-system automation includes processes associated with generation and delivery of power. Monitoring and control of power delivery systems in the substation and on the pole reduce the occurrence of outages and shorten the duration of outages that do occur. The IEDs, communications protocols, and communications methods, work together as a system to perform power-system automation. The term “power system” describes the collection of devices that make up the physical systems that generate, transmit, and distribute power. The term “instrumentation and control (I&C) system” refers to the collection of devices that monitor, control, and protect the power system. Many power-system automation are monitored by SCADA."]
18
+ ]
19
+
20
+ bellamy_bowie_note_quality = """<br><h3>A note on Bellamy Bowie's precision:</h3>
21
+ TBD TBD TBD
22
+ """
23
+
24
+ bellamy_bowie_article = """<br><h3>Discover which AI technologies are used for this demo and how easy it is to develop your own AI demo apps!</h3>
25
+ <ul>
26
+ <li>Check out the Hugging Face 🤗 introduction to <a href="https://huggingface.co/tasks/zero-shot-classification">Zero-Shot Classification</a> with transformers!</li>
27
+ <li>Discover Bellamy Bowie's secret weapon, the AI transformer model <a href="https://huggingface.co/facebook/bart-large-mnli">facebook/bart-large-mnli</a> with its checkpoint after being trained on the MultiNLI (MNLI) dataset!</li>
28
+ <li>Learn to develop your own AI apps with <a href="https://huggingface.co/learn/nlp-course/chapter9/1">Hugging Face</a> and <a href="https://www.gradio.app/">Gradio</a>!</li>
29
+ <li>Use the source code of our fascinating Ellis Cappy <a href="https://code.siemens.com/andreas.stein/aida-demos-use-cases">@code.siemens.com</a> to jump-start this exciting endeavor!</li>
30
+ </ul>
31
+ """
32
+
33
+ # Urly & Murly Simmy
34
+
35
+
36
+ # Ellis Cappy
37
+
38
  ellis_cappy_description = """
39
+ <h1>Meet Ellis Cappy: The Quacktastic Caption Creator!</h1><br>
40
+ Why rely on lazy humans when you can have an AI duck with flair? 🤖🦆<br><br>
41
+ Ellis Cappy is on a mission to turn mundane visuals into quackingly good content and is the feathered genius behind our image captions! 📸🌟<br><br>
42
+ Our superior AI duck waddles through pixelated landscapes, its webbed feet tapping out witty one-liners faster than a duckling chasing breadcrumbs. 📝💨<br><br><br>
43
+ """
44
+
45
+ ellis_cappy_hero = "https://images.nightcafe.studio/jobs/1tLpG6zZANbrgG4ds8wF/1tLpG6zZANbrgG4ds8wF--4--andnn.jpg"
46
+
47
+ ellis_cappy_examples = [
48
+ ["https://assets.new.siemens.com/siemens/assets/api/uuid:44d7dd1b-0c97-4a1a-be13-7506bbe1c6ed/width:4320/44d7dd1b-0c97-4a1a-be13-7506bbe1c6ed.webp"],
49
+ ["https://images.sw.cdn.siemens.com/siemens-disw-assets/public/5If52aTZJApP4ZmMGtqExa/en-US/heimon-kala_heimon_kala_76070_heroimage_1280x720_tcm27_59569.jpg"],
50
+ ["https://assets.new.siemens.com/siemens/assets/api/uuid:e444e60c-f8c0-444c-ad8a-e88b05b359bf/width:640/quality:high/Energy-automation.webp"],
51
+ ["https://assets.new.siemens.com/siemens/assets/api/uuid:7e606e7b-6dcb-44d0-b2cc-a6ca30adab34/width:1024/smo-blw-key-rendering-fixed.jpg"]
52
+ ]
53
+
54
+ ellis_cappy_note_quality = """<br><h3>A note on Ellis Cappy's precision:</h3>
55
+ Ellis Cappy started at Siemens just last week and, like all newcomers, was overwhelmed by our extremely relaxed tone,
56
+ our galactic speed despite/ and our legendary complexity.
57
+ Ellis' captions may therefore be a bit stilted and off-topic.
58
+ But once she completes our rigorous new hire program, she will be able to fabulate fluently like all of us...
59
+ """
60
+
61
+ ellis_cappy_article = """<br><h3>Discover which AI technologies are used for this demo and how easy it is to develop your own AI demo apps!</h3>
62
+ <ul>
63
+ <li>Read about the NLP task <a href="https://huggingface.co/tasks/image-to-text">image-to-text</a> with transformers!</li>
64
+ <li>Discover the AI transformer model <a href="https://huggingface.co/Salesforce/blip-image-captioning-base">Salesforce/blip-image-captioning-base</a> used for the Ellis Cappy demo!</li>
65
+ <li>Learn to develop your own AI apps with <a href="https://huggingface.co/learn/nlp-course/chapter9/1">Hugging Face</a> and <a href="https://www.gradio.app/">Gradio</a>!</li>
66
+ <li>Use the source code of our fascinating Ellis Cappy <a href="https://code.siemens.com/andreas.stein/aida-demos-use-cases">@code.siemens.com</a> to jump-start this exciting endeavor!</li>
67
+ </ul>
68
+ """
69
+
scratch.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from resources import *
3
+ from transformers import pipeline
4
+
5
+ # Bellamy Bowie stuff
6
+
7
+ bellamy_bowie_classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
8
+
9
+ bellamy_bowie_classifier_candidate_labels = ["manager", "engineer", "technician", "politician", "scientist", "student", "journalist", "marketeer", "spokesperson", "other"]
10
+ bellamy_bowie_classifier_candidate_labels_preselection = ["manager", "engineer", "technician", "politician", "scientist", "student", "journalist"]
11
+
12
+
13
+ def bellamy_bowie_predict(candidate_labels_selected, sequence):
14
+ outputs = bellamy_bowie_classifier(sequence, candidate_labels_selected)
15
+ return dict(zip(outputs['labels'], outputs['scores'])) # Extract labels and scores from the outputs dictionary
16
+
17
+
18
+ # Ellis Cappy stuff
19
+
20
+ ellis_cappy_captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base", max_new_tokens=40)
21
+
22
+
23
+ def ellis_cappy_captionizer(img):
24
+ captions = ellis_cappy_captioner(img)
25
+ return captions[0]["generated_text"]
26
+
27
+
28
+ with gr.Blocks() as aidademo:
29
+ with gr.Tab("Bellamy Bowie"):
30
+ with gr.Row():
31
+ with gr.Column(scale=3):
32
+ gr.HTML(bellamy_bowie_description)
33
+ with gr.Column(scale=1):
34
+ gr.Image(bellamy_bowie_hero)
35
+ with gr.Row():
36
+ with gr.Column(scale=1):
37
+ bellamy_bowie_checkbox_input = gr.CheckboxGroup(choices=bellamy_bowie_classifier_candidate_labels, value=bellamy_bowie_classifier_candidate_labels_preselection, label="Target personas of your message", info="Recommendation: Don't change the preselection for your first analysis."),
38
+ bellamy_bowie_textbox_input = gr.Textbox(lines=10, placeholder="Your text goes here", label="Write or paste your message to classify")
39
+ bellamy_bowie_submit_button = gr.Button("Submit")
40
+ with gr.Column(scale=1):
41
+ bellamy_bowie_outputs = gr.Label(label="Matching scores by personas")
42
+ gr.HTML(bellamy_bowie_note_quality)
43
+ with gr.Row():
44
+ with gr.Column(scale=1):
45
+ gr.Examples(bellamy_bowie_examples, inputs=[bellamy_bowie_textbox_input])
46
+ gr.HTML(bellamy_bowie_article)
47
+
48
+ with gr.Tab("Ellis Cappy"):
49
+ gr.HTML(ellis_cappy_description)
50
+ gr.Image("https://images.nightcafe.studio/jobs/1tLpG6zZANbrgG4ds8wF/1tLpG6zZANbrgG4ds8wF--4--andnn.jpg",
51
+ min_width=548)
52
+ with gr.Tab("Ellis Cappy"):
53
+ with gr.Row():
54
+ with gr.Column(scale=3):
55
+ gr.HTML(ellis_cappy_description)
56
+ with gr.Column(scale=1):
57
+ gr.Image(ellis_cappy_hero)
58
+ with gr.Row():
59
+ with gr.Column(scale=1):
60
+ ellis_cappy_image_input = gr.Image(type="pil", label=None)
61
+ ellis_cappy_submit_button = gr.Button("Submit")
62
+ with gr.Column(scale=1):
63
+ ellis_cappy_textbox_output = gr.Textbox(label="Suggested caption", lines=2)
64
+ gr.HTML(ellis_cappy_note_quality)
65
+ with gr.Row():
66
+ with gr.Column(scale=1):
67
+ gr.Examples(ellis_cappy_examples, inputs=[ellis_cappy_image_input])
68
+ gr.HTML(ellis_cappy_article)
69
+
70
+ ellis_cappy_submit_button.click(fn=ellis_cappy_captionizer, inputs=ellis_cappy_image_input,
71
+ outputs=ellis_cappy_textbox_output, api_name="captionizer")
72
+ bellamy_bowie_submit_button.click(fn=bellamy_bowie_predict,
73
+ inputs=[bellamy_bowie_checkbox_input, bellamy_bowie_textbox_input],
74
+ outputs=bellamy_bowie_outputs)
75
+
76
+ aidademo.launch()
scratch_2.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from resources import *
4
+
5
+ bellamy_bowie_classifier_candidate_labels = ["manager", "engineer", "technician", "politician", "scientist", "student", "journalist", "marketeer", "spokesperson", "other"]
6
+ bellamy_bowie_classifier_candidate_labels_preselection = ["manager", "engineer", "technician", "politician", "scientist", "student", "journalist"]
7
+
8
+ bellamy_bowie_classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
9
+
10
+
11
+ def bellamy_bowie_predict(candidate_labels_selected, sequence):
12
+ outputs = bellamy_bowie_classifier(sequence, candidate_labels_selected)
13
+ return dict(zip(outputs['labels'], outputs['scores'])) # Extract labels and scores from the outputs dictionary
14
+
15
+
16
+ def ellis_update(name, age):
17
+ return f"Welcome to Gradio, {name}! Are your really good {age} years old?"
18
+ # Ellis Cappy stuff
19
+
20
+ ellis_cappy_captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base", max_new_tokens=40)
21
+
22
+
23
+ def ellis_cappy_captionizer(img):
24
+ captions = ellis_cappy_captioner(img)
25
+ return captions[0]["generated_text"]
26
+
27
+
28
+ def marvin_update(origin, name):
29
+ # origin = type(origin)
30
+ return f"Welcome to Gradio, {name}! Are your really from {origin[0]}?"
31
+
32
+
33
+ with gr.Blocks() as demo:
34
+ gr.Markdown("Start typing below and then click **Run** to see the output.")
35
+
36
+ with gr.Tab("Bellamy Bowie"):
37
+ with gr.Row():
38
+ with gr.Column(scale=3):
39
+ gr.HTML(bellamy_bowie_description)
40
+ with gr.Column(scale=1):
41
+ gr.Image(bellamy_bowie_hero, label=None)
42
+ with gr.Row():
43
+ with gr.Column(scale=1):
44
+ bellamy_bowie_checkbox_input = gr.CheckboxGroup(choices=bellamy_bowie_classifier_candidate_labels, value=bellamy_bowie_classifier_candidate_labels_preselection, label="Target personas of your message", info="Recommendation: Don't change the preselection for your first analysis.")
45
+ bellamy_bowie_textbox_input = gr.Textbox(lines=10, placeholder="Your text goes here", label="Write or paste your message to classify")
46
+ with gr.Row():
47
+ bellamy_bowie_clear_button = gr.ClearButton(components=bellamy_bowie_textbox_input, value="Clear")
48
+ bellamy_bowie_submit_button = gr.Button("Submit", variant="primary")
49
+ with gr.Column(scale=1):
50
+ bellamy_bowie_outputs = gr.Label(label="Matching scores by personas")
51
+ gr.HTML(bellamy_bowie_note_quality)
52
+ with gr.Row():
53
+ with gr.Column(scale=1):
54
+ gr.Examples(bellamy_bowie_examples, inputs=[bellamy_bowie_textbox_input])
55
+ gr.HTML(bellamy_bowie_article)
56
+ bellamy_bowie_submit_button.click(fn=bellamy_bowie_predict, inputs=[bellamy_bowie_checkbox_input, bellamy_bowie_textbox_input], outputs=bellamy_bowie_outputs)
57
+
58
+ with gr.Tab("Urly & Murly Simmy"):
59
+ with gr.Row():
60
+ with gr.Column(scale=3):
61
+ gr.HTML(ellis_cappy_description)
62
+ with gr.Column(scale=1):
63
+ gr.Image(ellis_cappy_hero)
64
+ with gr.Row():
65
+ inp_01 = gr.Textbox(placeholder="What is your name?")
66
+ inp_02 = gr.Textbox(placeholder="What is your age?")
67
+ out_0 = gr.Textbox()
68
+ btn_0 = gr.Button("Run")
69
+ btn_0.click(fn=ellis_update, inputs=[inp_01, inp_02], outputs=out_0)
70
+
71
+ with gr.Tab("Ellis Cappy"):
72
+ with gr.Row():
73
+ with gr.Column(scale=3):
74
+ gr.HTML(ellis_cappy_description)
75
+ with gr.Column(scale=1):
76
+ gr.Image(ellis_cappy_hero)
77
+ with gr.Row():
78
+ with gr.Column(scale=1):
79
+ ellis_cappy_image_input = gr.Image(type="pil", label=None)
80
+ ellis_cappy_submit_button = gr.Button("Submit")
81
+ with gr.Column(scale=1):
82
+ ellis_cappy_textbox_output = gr.Textbox(label="Suggested caption", lines=2)
83
+ gr.HTML(ellis_cappy_note_quality)
84
+ with gr.Row():
85
+ with gr.Column(scale=1):
86
+ gr.Examples(ellis_cappy_examples, inputs=[ellis_cappy_image_input])
87
+ gr.HTML(ellis_cappy_article)
88
+
89
+ ellis_cappy_submit_button.click(fn=ellis_cappy_captionizer, inputs=ellis_cappy_image_input,
90
+ outputs=ellis_cappy_textbox_output, api_name="captionizer")
91
+
92
+ demo.launch()