boris commited on
Commit
3666d7b
1 Parent(s): cbfa520

feat: fix import error

Browse files
Files changed (2) hide show
  1. app/streamlit/app.py +20 -1
  2. app/streamlit/backend.py +0 -20
app/streamlit/app.py CHANGED
@@ -1,9 +1,28 @@
1
  #!/usr/bin/env python
2
  # coding: utf-8
3
 
 
 
 
 
4
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- from .backend import ServiceError, get_images_from_backend
7
 
8
  st.sidebar.markdown(
9
  """
 
1
  #!/usr/bin/env python
2
  # coding: utf-8
3
 
4
+ import base64
5
+ from io import BytesIO
6
+
7
+ import requests
8
  import streamlit as st
9
+ from PIL import Image
10
+
11
+
12
+ class ServiceError(Exception):
13
+ def __init__(self, status_code):
14
+ self.status_code = status_code
15
+
16
+
17
+ def get_images_from_backend(prompt, backend_url):
18
+ r = requests.post(backend_url, json={"prompt": prompt})
19
+ if r.status_code == 200:
20
+ images = r.json()["images"]
21
+ images = [Image.open(BytesIO(base64.b64decode(img))) for img in images]
22
+ return images
23
+ else:
24
+ raise ServiceError(r.status_code)
25
 
 
26
 
27
  st.sidebar.markdown(
28
  """
app/streamlit/backend.py DELETED
@@ -1,20 +0,0 @@
1
- import base64
2
- from io import BytesIO
3
-
4
- import requests
5
- from PIL import Image
6
-
7
-
8
- class ServiceError(Exception):
9
- def __init__(self, status_code):
10
- self.status_code = status_code
11
-
12
-
13
- def get_images_from_backend(prompt, backend_url):
14
- r = requests.post(backend_url, json={"prompt": prompt})
15
- if r.status_code == 200:
16
- images = r.json()["images"]
17
- images = [Image.open(BytesIO(base64.b64decode(img))) for img in images]
18
- return images
19
- else:
20
- raise ServiceError(r.status_code)