Skip to content

Commit

Permalink
Flux bug (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoarceof authored Oct 15, 2024
1 parent c8639aa commit d4542af
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/flux/app.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import os
import base64
import shutil
import requests
import replicate

from PIL import Image
from io import BytesIO
import shutil


def flux_image(prompt, filename):
output = replicate.run("black-forest-labs/flux-dev", input={"prompt": prompt})
image_url = 'http://' + output[0]

response = requests.get(image_url)
response.raise_for_status()
header, encoded = output[0].url.split(',', 1)

image = Image.open(BytesIO(response.content))
data = base64.b64decode(encoded)
image = Image.open(BytesIO(data))
image.save(filename, format="JPEG")

shutil.copy(filename, f"storage/{filename}")

prompt = input()
flux_image(prompt, "hal9-flux.jpg")
flux_image(prompt, "hal9-flux.jpg")

0 comments on commit d4542af

Please sign in to comment.