5m4ck3r commited on
Commit
ac67a14
·
verified ·
1 Parent(s): 1020f04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -10,7 +10,7 @@ from PIL import Image
10
  import os
11
 
12
  token = os.environ["API_TOKEN"]
13
-
14
  dtype = torch.bfloat16
15
  device = "cuda" if torch.cuda.is_available() else "cpu"
16
 
@@ -20,15 +20,20 @@ MAX_IMAGE_SIZE = 2048
20
  def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):
21
  if randomize_seed:
22
  seed = random.randint(0, MAX_SEED)
23
- model = InferenceClient("black-forest-labs/FLUX.1-schnell", token=prompt)
24
- image = model(prompt)
 
 
 
 
 
25
  temp_dir = tempfile.gettempdir()
26
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg", dir=temp_dir)
27
  image.save(temp_file, format="JPEG")
28
  temp_file_path = temp_file.name
29
  temp_file.close()
30
  return temp_file_path, seed
31
-
32
  examples = [
33
  "a tiny astronaut hatching from an egg on the moon",
34
  "a cat holding a sign that says hello world",
 
10
  import os
11
 
12
  token = os.environ["API_TOKEN"]
13
+ model = InferenceClient("black-forest-labs/FLUX.1-schnell", token=token)
14
  dtype = torch.bfloat16
15
  device = "cuda" if torch.cuda.is_available() else "cpu"
16
 
 
20
  def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, num_inference_steps=4, progress=gr.Progress(track_tqdm=True)):
21
  if randomize_seed:
22
  seed = random.randint(0, MAX_SEED)
23
+ image = client.text_to_image(
24
+ "A girl and a boy dancing in the forest",
25
+ height=height,
26
+ width=width,
27
+ seed=seed,
28
+ num_inference_steps=4
29
+ )
30
  temp_dir = tempfile.gettempdir()
31
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".jpg", dir=temp_dir)
32
  image.save(temp_file, format="JPEG")
33
  temp_file_path = temp_file.name
34
  temp_file.close()
35
  return temp_file_path, seed
36
+
37
  examples = [
38
  "a tiny astronaut hatching from an egg on the moon",
39
  "a cat holding a sign that says hello world",