multimodalart HF staff commited on
Commit
85b0174
1 Parent(s): 3329d94

First commit

Browse files
Files changed (2) hide show
  1. app.py +66 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from diffusers import UnCLIPPipeline
4
+
5
+ pipe = UnCLIPPipeline.from_pretrained("kakaobrain/karlo-v1-alpha", torch_dtype=torch.float16)
6
+ pipe = pipe.to("cuda")
7
+
8
+ def run(prompt):
9
+ images = pipe([prompt]*6).images
10
+ return images
11
+
12
+ css = '''
13
+ .container{max-width: 800px}
14
+ #title_area{text-align: center}
15
+ .footer {margin-bottom: 45px;text-align: center;border-bottom: 1px solid #e5e5e5}
16
+ .footer>p {font-size: .8rem;display: inline-block;padding: 0 10px;transform: translateY(10px);background: white}
17
+ .dark .footer {border-color: #303030}
18
+ .dark .footer>p {background: #0b0f19}
19
+ .acknowledgments h4{margin: 1.25em 0 .25em 0;font-weight: bold;font-size: 115%}
20
+ '''
21
+
22
+ with gr.Blocks(css=css) as demo:
23
+ with gr.Column(variant="panel"):
24
+ gr.Markdown('''## Karlo - unCLIP model by KakaoBrain
25
+ ##### First [open source implementation](https://github.com/kakaobrain/karlo) of unCLIP, the DALL-E 2 technique. For more try our [B^Discover app](https://huggingface.co/kakaobrain/karlo-v1-alpha)
26
+ ''', elem_id="title_area")
27
+ with gr.Row(variant="compact"):
28
+ text = gr.Textbox(
29
+ label="Enter your prompt",
30
+ show_label=False,
31
+ max_lines=1,
32
+ placeholder="Enter your prompt",
33
+ ).style(
34
+ container=False,
35
+ )
36
+ btn = gr.Button("Generate image").style(full_width=False)
37
+
38
+ gallery = gr.Gallery(
39
+ label="Generated images", show_label=False, elem_id="gallery"
40
+ ).style(grid=[3], height="auto")
41
+ text.submit(run, text, gallery)
42
+ btn.click(run, text, gallery)
43
+ examples = ["A man with a face of avocado, in the drawing style of Rene Magritte", "a black porcelain in the shape of pikachu", "a portrait of an old monk, highly detailed", "A teddy bear on a skateboard, children drawing style.", ]
44
+ ex = gr.Examples(examples=examples, fn=run, inputs=text, outputs=gallery, cache_examples=True)
45
+ ex.dataset.headers = [""]
46
+ gr.HTML('''
47
+ <p style="text-align: center;font-size: 94%">
48
+ For Faster Results you can skip the queue by duplicating this space:&nbsp;&nbsp;
49
+ <a style="display: inline-block" href="https://huggingface.co/kakaobrain/karlo?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>
50
+ </p>
51
+ ''')
52
+ gr.HTML(
53
+ """
54
+ <div class="footer">
55
+ <p>Model by <a href="https://huggingface.co/kakaobrain" style="text-decoration: underline;" target="_blank">KakaoBrain</a> - Gradio Demo running on 🧨 diffusers by 🤗 Hugging Face
56
+ </p>
57
+ </div>
58
+ <div class="acknowledgments">
59
+ <p><h4>LICENSE</h4>
60
+ The model is licensed with a <a href="https://github.com/kakaobrain/karlo/blob/main/LICENSE" style="text-decoration: underline;" target="_blank">CreativeML OpenRAIL</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
61
+ <p><h4>Biases and content acknowledgment</h4>
62
+ Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on a filtered subset of the <a href="https://github.com/kakaobrain/coyo-dataset" style="text-decoration: underline;" target="_blank">COYO-700M dataset</a>, which scraped image-text-pairs from the internet for research purposes. You can read more in the <a href="https://huggingface.co/kakaobrain/karlo-v1-alpha" style="text-decoration: underline;" target="_blank">model card</a></p>
63
+ </div>
64
+ """
65
+ )
66
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ diffusers==0.11.0
2
+ transformers==4.25.1
3
+ safetensors==0.2.6
4
+ accelerate==0.15.0