Skip to content

Commit

Permalink
fixing flux bug (#442)
Browse files Browse the repository at this point in the history
* fixing flux bug

* added specific replicate version
  • Loading branch information
diegoarceof authored Oct 30, 2024
1 parent e5c6659 commit a47c2dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions apps/flux/app.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import os
import base64
import shutil
import requests
import replicate

from PIL import Image
from io import BytesIO


def flux_image(prompt, filename):
output = replicate.run("black-forest-labs/flux-dev", input={"prompt": prompt})
try:
output = replicate.run("black-forest-labs/flux-dev", input={"prompt": prompt})
except Exception as e:
print("Couldn't generate that image. Please try a different prompt.")
print(f"Error: {e}")

header, encoded = output[0].url.split(',', 1)
encoded_image = output[0].read()
image = Image.open(BytesIO(encoded_image))

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

shutil.copy(filename, f".storage/{filename}")
Expand Down
2 changes: 1 addition & 1 deletion apps/flux/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
replicate
replicate==1.0.0

0 comments on commit a47c2dd

Please sign in to comment.