Spaces:
Running
Running
copperwiring
commited on
Commit
·
bddfb4b
1
Parent(s):
3e660e4
all working files
Browse files- .gitignore +13 -0
- README.md +39 -0
- app.py +53 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__/
|
2 |
+
*.py[cod]
|
3 |
+
*$py.class
|
4 |
+
.env
|
5 |
+
.venv
|
6 |
+
env/
|
7 |
+
venv/
|
8 |
+
ENV/
|
9 |
+
env.bak/
|
10 |
+
venv.bak/
|
11 |
+
.ipynb_checkpoints
|
12 |
+
.DS_Store
|
13 |
+
flagged/
|
README.md
CHANGED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Image Cultural Analysis App
|
2 |
+
|
3 |
+
A Gradio-powered app for creating dataset for cultural aspects of images in SE Asia.
|
4 |
+
|
5 |
+
## Features
|
6 |
+
|
7 |
+
- Upload images via upload button or webcam
|
8 |
+
- Answer questions about the cultural relevance of the image
|
9 |
+
- Provide location information (city and country)
|
10 |
+
- Assess cultural relevance to South-East Asia
|
11 |
+
- Add captions in native and English languages
|
12 |
+
|
13 |
+
## Deployment
|
14 |
+
|
15 |
+
This app is designed to be deployed to Hugging Face Spaces. To deploy:
|
16 |
+
|
17 |
+
1. Create a new Space on Hugging Face: https://huggingface.co/new-space
|
18 |
+
2. Select Gradio as the SDK
|
19 |
+
3. Upload these files to the Space's repository
|
20 |
+
4. The app will automatically deploy
|
21 |
+
|
22 |
+
## Local Development
|
23 |
+
|
24 |
+
To run this app locally:
|
25 |
+
|
26 |
+
```bash
|
27 |
+
pip install -r requirements.txt
|
28 |
+
python app.py
|
29 |
+
```
|
30 |
+
|
31 |
+
## Structure
|
32 |
+
|
33 |
+
- `app.py`: Main application code for the Gradio interface
|
34 |
+
- `requirements.txt`: Dependencies required for the app
|
35 |
+
- `README.md`: Documentation
|
36 |
+
|
37 |
+
## License
|
38 |
+
|
39 |
+
MIT
|
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def process_submission(input_img, text_answer, multiple_choice, city, country, se_asia_relevance, culture_knowledge, native_caption, english_caption):
|
4 |
+
# Just return the inputs to demonstrate they were received
|
5 |
+
# No ML pipeline processing here
|
6 |
+
return input_img, f"Your text response: {text_answer}", f"Your selected option: {multiple_choice}", f"Location: {city}, {country}", f"SE Asia relevance: {se_asia_relevance}", f"Cultural knowledge source: {culture_knowledge}", f"Native caption: {native_caption}", f"English caption: {english_caption}"
|
7 |
+
|
8 |
+
gradio_app = gr.Interface(
|
9 |
+
process_submission,
|
10 |
+
inputs=[
|
11 |
+
gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil"),
|
12 |
+
gr.Textbox(label="The image portrays culturally-relevant information in:", placeholder="what culture does this image represent?"),
|
13 |
+
# gr.Radio(choices=["North America", "South America", "Europe", "Africa", "Asia", "Australia"],
|
14 |
+
# label="Which continent is most represented in this image?"),
|
15 |
+
gr.Textbox(label="City where the image was taken:", placeholder="Enter city name"),
|
16 |
+
gr.Textbox(label="Country where the image was taken:", placeholder="Enter country name"),
|
17 |
+
gr.Radio(
|
18 |
+
choices=[
|
19 |
+
"Yes. Unique to South East",
|
20 |
+
"Yes, people will likely think of South East when seeing the picture, but it may have low degree of similarity to other cultures.",
|
21 |
+
"Maybe, this culture did not originate from South East, but it's quite dominant in South East",
|
22 |
+
"Not really. It has some affiliation to South East, but actually does not represent South East or has stronger affiliation to cultures outside South East",
|
23 |
+
"No. Totally unrelated to South East"
|
24 |
+
],
|
25 |
+
label="Is the image culturally relevant in South-East Asia?"
|
26 |
+
),
|
27 |
+
gr.Radio(
|
28 |
+
choices=[
|
29 |
+
"I'm from this country/culture",
|
30 |
+
"I checked online resources (e.g., Wikipedia, articles, blogs)"
|
31 |
+
],
|
32 |
+
label="How do you know about this culture?",
|
33 |
+
info="Please do not consult LLMs (e.g., GPT-4o, Claude, Command-R, etc.)"
|
34 |
+
),
|
35 |
+
gr.Textbox(label="Caption in Native Language:", placeholder="Enter caption in the native language of the culture depicted"),
|
36 |
+
gr.Textbox(label="English Caption:", placeholder="Enter caption in English")
|
37 |
+
],
|
38 |
+
outputs=[
|
39 |
+
gr.Image(label="Submitted Image"),
|
40 |
+
gr.Text(label="Text Response"),
|
41 |
+
gr.Text(label="Multiple Choice Response"),
|
42 |
+
gr.Text(label="Location Information"),
|
43 |
+
gr.Text(label="South-East Asia Cultural Relevance"),
|
44 |
+
gr.Text(label="Cultural Knowledge Source"),
|
45 |
+
gr.Text(label="Native Language Caption"),
|
46 |
+
gr.Text(label="English Caption")
|
47 |
+
],
|
48 |
+
title="Image Cultural Analysis",
|
49 |
+
description="Upload an image and answer questions about its cultural significance."
|
50 |
+
)
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
+
gradio_app.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio==4.*
|
2 |
+
Pillow>=9.0.0
|