sandz7 commited on
Commit
17fc7b8
Β·
1 Parent(s): e13b86a

first start for osiris

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from diffusers import DiffusionPipeline
4
+ import os
5
+
6
+ # UI
7
+ DESCRIPTION = '''
8
+ <div>
9
+ <h1 style="text-align: center;">Osiris πŸ¦₯</h1>
10
+ <p>This has an open source stable diffuser from <a href="https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0"><b>stable-diffusion-xl-base-1.0</b></a></p>
11
+ </div>
12
+ '''
13
+
14
+ # pipeline
15
+ pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16").to('cuda')
16
+
17
+ # function to take input and generate text tokena
18
+ def osiris(prompt: str,
19
+ history: list,
20
+ temperature: float,
21
+ max_new_tokens: int):
22
+ """
23
+ Takes input, passes it into the pipeline,
24
+ get the top 5 scores, and ouput those scores into images
25
+ """
26
+
27
+ # Generate image based on text
28
+ image = pipeline(prompt=prompt).images[0]
29
+
30
+ return image
31
+
32
+ with gr.Blocks(fill_height=True) as demo:
33
+ gr.Markdown(DESCRIPTION)
34
+ gr.Interface(
35
+ fn=osiris,
36
+ inputs="text",
37
+ outputs="image",
38
+ fill_height=True,
39
+ # additional_inputs_accordion=gr.Accordion(label="βš™οΈ Parameters", open=False, render=False),
40
+ # additional_inputs=[]
41
+ )
42
+
43
+ if __name__ == "__main__":
44
+ demo.launch()