Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,35 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
return output_image
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|