VashTheStampede123 commited on
Commit
9b41eff
Β·
0 Parent(s):

initial commit

Browse files
Files changed (4) hide show
  1. .github/workflows/sync-to-space.yaml +19 -0
  2. .gitignore +2 -0
  3. app.py +52 -0
  4. requirements.txt +0 -0
.github/workflows/sync-to-space.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face Space
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ sync-to-hub:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ with:
13
+ fetch-depth: 0
14
+ lfs: true
15
+ - name: Push to Space
16
+ env:
17
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
18
+ run: |
19
+ git push https://HF_USERNAME:${HF_TOKEN}@huggingface.co/spaces/HF_USERNAME/SPACE_NAME main
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .venv
2
+ .idea
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dependencies
2
+ import os
3
+ import streamlit as st
4
+ from huggingface_hub import InferenceClient
5
+
6
+ def create_image(prompt):
7
+ """
8
+ Creating an image from a text prompt.
9
+ """
10
+ # output is a PIL.Image object
11
+ image = client.text_to_image(
12
+ prompt,
13
+ model="nerijs/dark-fantasy-illustration-flux"
14
+ )
15
+
16
+ return image
17
+
18
+ def Interface():
19
+ """
20
+ Creating a streamlit interface
21
+ """
22
+
23
+ st.set_page_config(
24
+ page_title="Dark Fantasy Image Generator", # Title of the browser tab
25
+ page_icon="πŸ¦β€πŸ”₯", # Favicon (can be emoji or image URL)
26
+ layout="wide", # Options: "centered" (default) or "wide"
27
+ initial_sidebar_state="expanded", # Options: "auto", "expanded", "collapsed"
28
+ )
29
+
30
+ st.title('Dark Fantasy Image Generator')
31
+ st.caption('A project by Shivam Shinde')
32
+
33
+ prompt = st.text_area('Image Description')
34
+ if st.button('Generate Image'):
35
+ image = create_image(prompt)
36
+ st.image(image, caption="Image generated by the model: 'nerijs/dark-fantasy-illustration-flux'", use_container_width=True)
37
+
38
+
39
+ if __name__ == "__main__":
40
+
41
+ # Getting the API key
42
+ API_KEY = os.getenv("DarkFantasyImageGeneratorApp")
43
+
44
+ # Check if the key is retrieved correctly
45
+ if not API_KEY:
46
+ raise st.error("API Key not found.")
47
+
48
+ # Initialize the InferenceClient
49
+ client = InferenceClient(token=API_KEY)
50
+
51
+ # Launching the interface
52
+ Interface()
requirements.txt ADDED
File without changes