Spaces:
Sleeping
Sleeping
corrección de chatgpt
Browse files
app.py
CHANGED
@@ -1,46 +1,45 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
api_key = os.getenv('HF_API_KEY')
|
5 |
-
|
6 |
-
# with gr.Blocks() as demo:
|
7 |
-
# gr.load("fffiloni/sd-xl-custom-model", api_key=api_key, hf_token=api_key, src="spaces")
|
8 |
-
|
9 |
from gradio_client import Client
|
10 |
|
|
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
def predict(prompt):
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
with gr.Blocks() as demo:
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
demo.launch()
|
46 |
-
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from gradio_client import Client
|
4 |
|
5 |
+
api_key = os.getenv('HF_API_KEY')
|
6 |
|
7 |
+
custom_model = "lichorosario/dott_remastered_style_lora_sdxl"
|
8 |
+
weight_name = "dott_style.safetensors"
|
9 |
|
10 |
def predict(prompt):
|
11 |
+
client = Client("fffiloni/sd-xl-custom-model", api_key=api_key)
|
12 |
+
|
13 |
+
# Load the model
|
14 |
+
client.predict(
|
15 |
+
custom_model=custom_model,
|
16 |
+
api_name="/load_model"
|
17 |
+
)
|
18 |
+
|
19 |
+
# Infer the image
|
20 |
+
result = client.predict(
|
21 |
+
custom_model=custom_model,
|
22 |
+
weight_name=weight_name,
|
23 |
+
prompt=prompt,
|
24 |
+
inf_steps=25,
|
25 |
+
guidance_scale=12,
|
26 |
+
width=1024,
|
27 |
+
height=512,
|
28 |
+
seed=-1,
|
29 |
+
lora_weight=1,
|
30 |
+
api_name="/infer"
|
31 |
+
)
|
32 |
+
|
33 |
+
# Assuming result is a dictionary with keys 'image' and 'seed'
|
34 |
+
image = result["image"]
|
35 |
+
seed = result["seed"]
|
36 |
+
|
37 |
+
return image, seed
|
38 |
|
39 |
with gr.Blocks() as demo:
|
40 |
+
inputs = gr.Textbox(label="Prompt")
|
41 |
+
outputs = [gr.Image(label="Image"), gr.Textbox(label="Seed")]
|
42 |
+
greet_btn = gr.Button("Generate")
|
43 |
+
greet_btn.click(fn=predict, inputs=inputs, outputs=outputs)
|
44 |
|
45 |
demo.launch()
|
|