yourusername commited on
Commit
077ab50
0 Parent(s):

:tada: init

Browse files
.github/workflows/check_size.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Check file size
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+
7
+ # to run this workflow manually from the Actions tab
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ sync-to-hub:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Check large files
15
+ uses: ActionsDesk/lfs-warning@v2.0
16
+ with:
17
+ filesizelimit: 10485760 # = 10MB, so we can sync to HF spaces
.github/workflows/sync_to_hub.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ # to run this workflow manually from the Actions tab
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ sync-to-hub:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ with:
16
+ fetch-depth: 0
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push https://nateraw:$HF_TOKEN@huggingface.co/spaces/nateraw/huggingpics-explorer main --force
README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: huggingpics-explorer
3
+ emoji: 🤗
4
+ colorFrom: blue
5
+ colorTo: red
6
+ sdk: streamlit
7
+ app_file: app.py
8
+ pinned: false
9
+ ---
10
+
11
+ # huggingpics-explorer
12
+
13
+ [![Generic badge](https://img.shields.io/badge/🤗-Open%20In%20Spaces-blue.svg)](https://huggingface.co/spaces/nateraw/huggingpics-explorer)
14
+
15
+ A streamlit app for exploring image search results from HuggingPics
16
+
17
+ ---
18
+
19
+ Autogenerated using [this template](https://github.com/nateraw/spaces-template)
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from huggingpics.data import get_image_urls_by_term
3
+
4
+
5
+ def show_images_of_term(search_term, num_cols=5, num_rows=3):
6
+
7
+ # Get the image urls
8
+ # Arbitrarily adding 2 to make sure we have enough images in the event of a failed request
9
+ urls = get_image_urls_by_term(search_term, count=(num_rows * num_cols) + 2)
10
+
11
+ st.title(search_term)
12
+ for row_id in range(num_rows):
13
+ cols = st.columns(num_cols)
14
+ for col_id in range(num_cols):
15
+ cols[col_id].image(urls[row_id * num_cols + col_id], use_column_width=True)
16
+
17
+ def explore():
18
+ with st.sidebar:
19
+ term_1 = st.sidebar.text_input('Search Term 1', value='shiba inu')
20
+ term_2 = st.sidebar.text_input('Search Term 2', value='husky')
21
+ term_3 = st.sidebar.text_input('Search Term 3', value='')
22
+ term_4 = st.sidebar.text_input('Search Term 4', value='')
23
+ term_5 = st.sidebar.text_input('Search Term 5', value='')
24
+
25
+ terms = [t for t in [term_1, term_2, term_3, term_4, term_5] if t]
26
+
27
+ for term in terms:
28
+ show_images_of_term(term)
29
+
30
+
31
+ def create_dataset():
32
+ st.text("# Coming soon...")
33
+
34
+
35
+ def main():
36
+
37
+ with st.sidebar:
38
+ mode = st.sidebar.selectbox("Mode", ["Explore", "Create Dataset"])
39
+ st.sidebar.markdown("---")
40
+
41
+ _ = explore() if mode == "Explore" else create_dataset()
42
+
43
+
44
+
45
+ if __name__ == '__main__':
46
+ main()
packages.txt ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ streamlit
2
+ huggingpics