Ryukijano commited on
Commit
0afff03
·
1 Parent(s): d08701e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -18
app.py CHANGED
@@ -1,24 +1,35 @@
1
  import gradio as gr
 
2
 
3
- # Inference function takes prompt, negative prompt and image
4
- def infer(prompt, negative_prompt, image):
5
- # Implement your inference function here for ControlNet-based Fill Circle
6
- output_image = generate_fill_circle_image(prompt, negative_prompt, image) # Replace with your function
 
 
 
 
 
 
 
 
 
 
 
7
  return output_image
8
 
9
- title = "ControlNet on Fill Circle"
10
- description = "This is a demo on ControlNet based on fill circle."
 
 
 
 
 
 
 
 
 
 
11
 
12
- # You need to pass your examples according to your inputs
13
- # Each inner list is one example, each element in the list corresponding to a component in the `inputs`.
14
- examples = [["red circle with blue background", "cyan circle with brown floral background", None]]
15
 
16
- gr.Interface(
17
- fn = infer,
18
- inputs = ["text", "text", "image"],
19
- outputs = "image",
20
- title = title,
21
- description = description,
22
- examples = examples,
23
- theme='gradio/soft'
24
- ).launch()
 
1
  import gradio as gr
2
+ from transformers import FlaxAutoModel, AutoTokenizer
3
 
4
+ def load_model_and_tokenizer(model_name):
5
+ model = FlaxAutoModel.from_pretrained(model_name)
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ return model, tokenizer
8
+
9
+ def generate_image(model, tokenizer, prompt):
10
+ # Process the input prompt and generate the output image using the model and tokenizer
11
+ # ...
12
+ # output_image = ... (your implementation here)
13
+ return output_image
14
+
15
+ def infer(prompt):
16
+ model_name = "Ryukijano/controlnet-fill-circle"
17
+ model, tokenizer = load_model_and_tokenizer(model_name)
18
+ output_image = generate_image(model, tokenizer, prompt)
19
  return output_image
20
 
21
+ iface = gr.Interface(
22
+ fn=infer,
23
+ inputs=["text"],
24
+ outputs="image",
25
+ title="ControlNet Fill Circle",
26
+ description="This is a demo of ControlNet Fill Circle.",
27
+ examples=[
28
+ ["red circle with blue background"],
29
+ ["cyan circle with brown floral background"]
30
+ ],
31
+ theme="gradio/soft",
32
+ )
33
 
34
+ iface.launch()
 
 
35