Skip to content

Commit

Permalink
feat: fix import error
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdayma committed Nov 30, 2021
1 parent cbfa520 commit 3666d7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
21 changes: 20 additions & 1 deletion app/streamlit/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#!/usr/bin/env python
# coding: utf-8

import base64
from io import BytesIO

import requests
import streamlit as st
from PIL import Image


class ServiceError(Exception):
def __init__(self, status_code):
self.status_code = status_code


def get_images_from_backend(prompt, backend_url):
r = requests.post(backend_url, json={"prompt": prompt})
if r.status_code == 200:
images = r.json()["images"]
images = [Image.open(BytesIO(base64.b64decode(img))) for img in images]
return images
else:
raise ServiceError(r.status_code)

from .backend import ServiceError, get_images_from_backend

st.sidebar.markdown(
"""
Expand Down
20 changes: 0 additions & 20 deletions app/streamlit/backend.py

This file was deleted.

0 comments on commit 3666d7b

Please sign in to comment.