tamaraDD commited on
Commit
a4f85a8
·
verified ·
1 Parent(s): 6a10d55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -1,11 +1,18 @@
1
  import gradio as gr
2
  import replicate
3
 
4
- DEPLOYMENT_URI = "dd-ds-ai/lora-test-01-deployment-test"
5
 
 
 
 
 
 
6
 
7
- def generate_image(lora_scale, guidance_scale, prompt_strength, num_steps, prompt):
8
- deployment = replicate.deployments.get(DEPLOYMENT_URI)
 
 
 
9
  prediction = deployment.predictions.create(
10
  input={
11
  "model": "dev",
@@ -21,6 +28,7 @@ def generate_image(lora_scale, guidance_scale, prompt_strength, num_steps, promp
21
  "prompt": prompt
22
  }
23
  )
 
24
  prediction.wait()
25
  output = prediction.output
26
  image_url = output[0] if output else None
@@ -29,23 +37,22 @@ def generate_image(lora_scale, guidance_scale, prompt_strength, num_steps, promp
29
 
30
  # Gradio-Interface erstellen
31
  def create_gradio_interface():
 
 
32
  lora_scale = gr.Slider(0, 2, value=1, step=0.1, label="Lora Scale")
33
  guidance_scale = gr.Slider(1, 10, value=3.5, step=0.1, label="Guidance Scale")
34
  prompt_strength = gr.Slider(0, 1, value=0.8, step=0.1, label="Prompt Strength")
35
  num_steps = gr.Slider(1, 50, value=28, step=1, label="Number of Inference Steps")
36
  prompt = gr.Textbox(label="Prompt", value="a person reading the hamburger abendblatt newspaper")
37
 
38
- # Erstelle ein Button-Interface für die Bildgenerierung
39
  generate_btn = gr.Button("Bild generieren")
40
 
41
- # Gradio Interface
42
  interface = gr.Interface(
43
- fn=generate_image, # Die Funktion, die aufgerufen wird
44
- inputs=[lora_scale, guidance_scale, prompt_strength, num_steps, prompt], # Eingaben
45
- outputs=gr.Image(label="Generated Image"), # Ausgabe als Bild
46
  )
47
 
48
- # Binde den Button an die Bildgenerierung
49
  interface.launch(share=True)
50
 
51
 
@@ -53,5 +60,4 @@ def create_gradio_interface():
53
  if __name__ == "__main__":
54
  create_gradio_interface()
55
 
56
-
57
- # demo.queue().launch()
 
1
  import gradio as gr
2
  import replicate
3
 
 
4
 
5
+ DEPLOYMENT_URIS = {
6
+ "Lora 500": "dd-ds-ai/lora-test-01-deployment-test",
7
+ "Lora 1000": "dd-ds-ai/lora-test-01-deployment-test",
8
+ "Lora 2000": "dd-ds-ai/lora-test-01-deployment-test"
9
+ }
10
 
11
+
12
+ def generate_image(model_selection, lora_scale, guidance_scale, prompt_strength, num_steps, prompt):
13
+ deployment_uri = DEPLOYMENT_URIS[model_selection]
14
+ deployment = replicate.deployments.get(deployment_uri)
15
+
16
  prediction = deployment.predictions.create(
17
  input={
18
  "model": "dev",
 
28
  "prompt": prompt
29
  }
30
  )
31
+
32
  prediction.wait()
33
  output = prediction.output
34
  image_url = output[0] if output else None
 
37
 
38
  # Gradio-Interface erstellen
39
  def create_gradio_interface():
40
+ model_selection = gr.Radio(choices=["Lora 500", "Lora 1000", "Lora 2000"], label="Model Selection", value="Lora 1000")
41
+
42
  lora_scale = gr.Slider(0, 2, value=1, step=0.1, label="Lora Scale")
43
  guidance_scale = gr.Slider(1, 10, value=3.5, step=0.1, label="Guidance Scale")
44
  prompt_strength = gr.Slider(0, 1, value=0.8, step=0.1, label="Prompt Strength")
45
  num_steps = gr.Slider(1, 50, value=28, step=1, label="Number of Inference Steps")
46
  prompt = gr.Textbox(label="Prompt", value="a person reading the hamburger abendblatt newspaper")
47
 
 
48
  generate_btn = gr.Button("Bild generieren")
49
 
 
50
  interface = gr.Interface(
51
+ fn=generate_image,
52
+ inputs=[model_selection, lora_scale, guidance_scale, prompt_strength, num_steps, prompt],
53
+ outputs=gr.Image(label="Generated Image"),
54
  )
55
 
 
56
  interface.launch(share=True)
57
 
58
 
 
60
  if __name__ == "__main__":
61
  create_gradio_interface()
62
 
63
+