Owos commited on
Commit
fe8fd9f
·
1 Parent(s): 13448cf

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import neural_style
2
+
3
+ import streamlit as st
4
+ import numpy as np
5
+ import cv2
6
+ from PIL import Image, ImageEnhance
7
+
8
+ #Create two columns with different width
9
+ col1, col2 = st.columns( [0.8, 0.2])
10
+ with col1: # To display the header text using css style
11
+ st.markdown(""" <style> .font {
12
+ font-size:35px ; font-family: 'Cooper Black'; color: #FF9633;}
13
+ </style> """, unsafe_allow_html=True)
14
+ st.markdown('<p class="font">Upload your photo here...</p>', unsafe_allow_html=True)
15
+
16
+ #Add a header and expander in side bar
17
+ st.sidebar.markdown('<p class="font">Afrodreams.AI</p>', unsafe_allow_html=True)
18
+ with st.sidebar.expander("About the App"):
19
+ st.write("""
20
+ This app takes in your image and styles it with a unique african art.""")
21
+
22
+ #Add file uploader to allow users to upload photos
23
+ uploaded_file = st.file_uploader("", type=['jpg','png','jpeg'])
24
+
25
+ #Add 'before' and 'after' columns
26
+ if uploaded_file is not None:
27
+ image = Image.open(uploaded_file)
28
+
29
+ col1, col2 = st.columns( [0.5, 0.5])
30
+ with col1:
31
+ st.markdown('<p style="text-align: center;">Before</p>',unsafe_allow_html=True)
32
+ st.image(image,width=300)
33
+
34
+ with col2:
35
+ st.markdown('<p style="text-align: center;">After</p>',unsafe_allow_html=True)
36
+
37
+ # add a button
38
+ run = st.button('Generate Art')
39
+ if run==True:
40
+ params = neural_style.TransferParams()
41
+ params.gpu = "c"
42
+ params.backend = "mkl"
43
+ params.image_size = 128
44
+ params.content_image = uploaded_file
45
+ neural_style.transfer(params)
46
+
47
+ #display image when done.
48
+ with col2:
49
+ result = Image.open('out.png')
50
+ st.image(result, width=300)
51
+ run =st.download_button(label="Download Image", data=result.tobytes(), file_name='afrodreams.png')
52
+
53
+
54
+
55
+ #img = neural_style.transfer(params)
56
+