CarstenF commited on
Commit
02cf149
·
1 Parent(s): 3ca4d00

change replicate to deployment instead of model

Browse files
Files changed (1) hide show
  1. app.py +7 -19
app.py CHANGED
@@ -1,25 +1,12 @@
1
- import gradio as gr
2
- import numpy as np
3
- import random
4
- from diffusers import DiffusionPipeline
5
- import torch
6
-
7
- device = "cuda" if torch.cuda.is_available() else "cpu"
8
-
9
- if torch.cuda.is_available():
10
- torch_dtype = torch.float16
11
- else:
12
- torch_dtype = torch.float32
13
-
14
- ####
15
-
16
  import gradio as gr
17
  import replicate
18
 
 
 
19
 
20
- def generate_image(lora_scale, guidance_scale, prompt_strength, num_steps, prompt):
21
- output = replicate.run(
22
- "dd-ds-ai/lora_test_01:70c669221124d8aaf0fc494f9553468bd069483a19e74b2753262008b1e8fbb2",
23
  input={
24
  "model": "dev",
25
  "lora_scale": lora_scale,
@@ -34,6 +21,7 @@ def generate_image(lora_scale, guidance_scale, prompt_strength, num_steps, promp
34
  "prompt": prompt
35
  }
36
  )
 
37
  image_url = output[0] if output else None
38
  return image_url
39
 
@@ -52,7 +40,7 @@ def create_gradio_interface():
52
  # Gradio Interface
53
  interface = gr.Interface(
54
  fn=generate_image, # Die Funktion, die aufgerufen wird
55
- inputs=[lora_scale, guidance_scale, prompt_strength, num_steps, prompt], # Eingaben
56
  outputs=gr.Image(label="Generated Image"), # Ausgabe als Bild
57
  )
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(deployment_uri, 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",
12
  "lora_scale": lora_scale,
 
21
  "prompt": prompt
22
  }
23
  )
24
+ prediction.wait()
25
  image_url = output[0] if output else None
26
  return image_url
27
 
 
40
  # Gradio Interface
41
  interface = gr.Interface(
42
  fn=generate_image, # Die Funktion, die aufgerufen wird
43
+ inputs=[DEPLOYMENT_URI, lora_scale, guidance_scale, prompt_strength, num_steps, prompt], # Eingaben
44
  outputs=gr.Image(label="Generated Image"), # Ausgabe als Bild
45
  )
46