RaghavenderReddy commited on
Commit
b22bc60
·
verified ·
1 Parent(s): b1b4949

Upload 3 files

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -3
  2. translations.py +229 -0
  3. utils.py +76 -0
requirements.txt CHANGED
@@ -1,3 +1,2 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ streamlit>=1.35.0
2
+ pillow>=10.0.0
 
translations.py ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Multilingual translation support for LabelIt! - Indian Languages Focus
3
+ """
4
+
5
+ SUPPORTED_LANGUAGES = {
6
+ 'en': 'English',
7
+ 'hi': 'हिन्दी (Hindi)',
8
+ 'te': 'తెలుగు (Telugu)'
9
+ }
10
+
11
+ TRANSLATIONS = {
12
+ 'en': {
13
+ 'app_subtitle': 'Multilingual Image Labeling Platform',
14
+ 'welcome': 'Welcome',
15
+ 'login': 'Login',
16
+ 'register': 'Register',
17
+ 'logout': 'Logout',
18
+ 'username': 'Username',
19
+ 'password': 'Password',
20
+ 'confirm_password': 'Confirm Password',
21
+ 'preferred_language': 'Preferred Language',
22
+ 'fill_all_fields': 'Please fill in all fields',
23
+ 'passwords_dont_match': 'Passwords do not match',
24
+ 'username_exists': 'Username already exists',
25
+ 'registration_successful': 'Registration successful! Please login.',
26
+ 'invalid_credentials': 'Invalid username or password',
27
+ 'login_successful': 'Login successful!',
28
+ 'upload_image': 'Upload Image',
29
+ 'choose_image': 'Choose an image',
30
+ 'image_help': 'Supported formats: PNG, JPG, JPEG, GIF (max 10MB)',
31
+ 'image_title': 'Image Title',
32
+ 'image_description': 'Image Description',
33
+ 'native_language_label': 'Label in Your Language',
34
+ 'category': 'Category',
35
+ 'upload': 'Upload',
36
+ 'upload_successful': 'Image uploaded successfully!',
37
+ 'image_feed': 'Image Feed',
38
+ 'filter_by_category': 'Filter by Category',
39
+ 'all': 'All',
40
+ 'animals': 'Animals',
41
+ 'food': 'Food',
42
+ 'objects': 'Objects',
43
+ 'nature': 'Nature',
44
+ 'people': 'People',
45
+ 'transportation': 'Transportation',
46
+ 'labels': 'Labels',
47
+ 'add_label': 'Add Label',
48
+ 'new_label': 'New Label',
49
+ 'label_language': 'Label Language',
50
+ 'enter_label': 'Please enter a label',
51
+ 'label_added': 'Label added successfully!',
52
+ 'label_exists': 'This label already exists',
53
+ 'no_images_yet': 'No images uploaded yet. Be the first to share!',
54
+ 'image_not_found': 'Image not found',
55
+ 'cancel': 'Cancel',
56
+ 'feed': 'Feed',
57
+ 'file_too_large': 'File size must be less than 10MB',
58
+ 'invalid_file_type': 'Invalid file type. Please upload PNG, JPG, JPEG, or GIF files.',
59
+ 'image_processing_error': 'Error processing image. Please try again.',
60
+ 'location_captured': 'Location captured',
61
+ 'location_not_available': 'Location not available',
62
+ 'get_location': 'Get Location',
63
+ 'user_details': 'User Details',
64
+ 'full_name': 'Full Name',
65
+ 'email': 'Email',
66
+ 'phone': 'Phone Number',
67
+ 'age': 'Age',
68
+ 'location_info': 'Location Info',
69
+ 'multilingual_image_labeling': 'Multilingual Image Labeling',
70
+ 'please_login': 'Please login to start using the application',
71
+ 'view_images': 'View Images',
72
+ 'please_fill_all_fields': 'Please fill in all fields',
73
+ 'please_fill_required_fields': 'Please fill in all required fields',
74
+ 'registration_success': 'Registration successful! Please login.',
75
+ 'login_success': 'Login successful!',
76
+ 'image_uploaded': 'Image uploaded successfully!',
77
+ 'no_images': 'No images available',
78
+ 'no_images_in_category': 'No images in this category',
79
+ 'no_labels': 'No labels available',
80
+ 'label_text': 'Label Text'
81
+ },
82
+ 'hi': {
83
+ 'app_subtitle': 'बहुभाषी छवि लेबलिंग प्लेटफॉर्म',
84
+ 'welcome': 'स्वागत है',
85
+ 'login': 'लॉगिन',
86
+ 'register': 'पंजीकरण',
87
+ 'logout': 'लॉगआउट',
88
+ 'username': 'उपयोगकर्ता नाम',
89
+ 'password': 'पासवर्ड',
90
+ 'confirm_password': 'पासवर्ड की पुष्टि करें',
91
+ 'preferred_language': 'पसंदीदा भाषा',
92
+ 'fill_all_fields': 'कृपया सभी फील्ड भरें',
93
+ 'passwords_dont_match': 'पासवर्ड मेल नहीं खाते',
94
+ 'username_exists': 'उपयोगकर्ता नाम पहले से मौजूद है',
95
+ 'registration_successful': 'पंजीकरण सफल! कृपया लॉगिन करें।',
96
+ 'invalid_credentials': 'गलत उपयोगकर्ता नाम या पासवर्ड',
97
+ 'login_successful': 'लॉगिन सफल!',
98
+ 'upload_image': 'छवि अपलोड करें',
99
+ 'choose_image': 'एक छवि चुनें',
100
+ 'image_help': 'समर्थित प्रारूप: PNG, JPG, JPEG, GIF (अधिकतम 10MB)',
101
+ 'image_title': 'छवि शीर्षक',
102
+ 'image_description': 'छवि विवरण',
103
+ 'native_language_label': 'आपकी भाषा में लेबल',
104
+ 'category': 'श्रेणी',
105
+ 'upload': 'अपलोड',
106
+ 'upload_successful': 'छवि सफलतापूर्वक अपलोड हुई!',
107
+ 'image_feed': 'छवि फीड',
108
+ 'filter_by_category': 'श्रेणी के अनुसार फिल्टर करें',
109
+ 'all': 'सभी',
110
+ 'animals': 'जानवर',
111
+ 'food': 'भोजन',
112
+ 'objects': 'वस्तुएं',
113
+ 'nature': 'प्रकृति',
114
+ 'people': 'लोग',
115
+ 'transportation': 'परिवहन',
116
+ 'labels': 'लेबल',
117
+ 'add_label': 'लेबल जोड़ें',
118
+ 'new_label': 'नया लेबल',
119
+ 'label_language': 'लेबल भाषा',
120
+ 'enter_label': 'कृपया एक लेबल दर्ज करें',
121
+ 'label_added': 'लेबल सफलतापूर्वक जोड़ा गया!',
122
+ 'label_exists': 'यह लेबल पहले से मौजूद है',
123
+ 'no_images_yet': 'अभी तक कोई छवि अपलोड नहीं की गई। पहले साझा करें!',
124
+ 'image_not_found': 'छवि नहीं मिली',
125
+ 'cancel': 'रद्द करें',
126
+ 'feed': 'फीड',
127
+ 'file_too_large': 'फाइल का आकार 10MB से कम होना चाहिए',
128
+ 'invalid_file_type': 'अमान्य फाइल प्रकार। कृपया PNG, JPG, JPEG, या GIF फाइलें अपलोड करें।',
129
+ 'image_processing_error': 'छवि प्रसंस्करण त्रुटि। कृपया पुनः प्रयास करें।',
130
+ 'location_captured': 'स्थान कैप्चर किया गया',
131
+ 'location_not_available': 'स्थान उपलब्ध नहीं है',
132
+ 'get_location': 'स्थान प्राप्त करें',
133
+ 'user_details': 'उपयोगकर्ता विवरण',
134
+ 'full_name': 'पूरा नाम',
135
+ 'email': 'ईमेल',
136
+ 'phone': 'फोन नंबर',
137
+ 'age': 'आयु',
138
+ 'location_info': 'स्थान जानकारी',
139
+ 'multilingual_image_labeling': 'बहुभाषी छवि लेबलिंग',
140
+ 'please_login': 'कृपया एप्लिकेशन का उपयोग शुरू करने के लिए लॉगिन करें',
141
+ 'view_images': 'छवियां देखें',
142
+ 'please_fill_all_fields': 'कृपया सभी फील्ड भरें',
143
+ 'please_fill_required_fields': 'कृपया सभी आवश्यक फील्ड भरें',
144
+ 'registration_success': 'पंजीकरण सफल! कृपया लॉगिन करें।',
145
+ 'login_success': 'लॉगिन सफल!',
146
+ 'image_uploaded': 'छवि सफलतापूर्वक अपलोड हुई!',
147
+ 'no_images': 'कोई छवि उपलब्ध नहीं',
148
+ 'no_images_in_category': 'इस श्रेणी में कोई छवि नहीं',
149
+ 'no_labels': 'कोई लेबल उपलब्ध नहीं',
150
+ 'label_text': 'लेबल टेक्स्ट'
151
+ },
152
+ 'te': {
153
+ 'app_subtitle': 'బహుభాషా చిత్ర లేబలింగ్ ప్లాట్‌ఫారమ్',
154
+ 'welcome': 'స్వాగతం',
155
+ 'login': 'లాగిన్',
156
+ 'register': 'నమోదు',
157
+ 'logout': 'లాగ్ అవుట్',
158
+ 'username': 'వినియోగదారు పేరు',
159
+ 'password': 'పాస్‌వర్డ్',
160
+ 'confirm_password': 'పాస్‌వర్డ్ నిర్ధారించండి',
161
+ 'preferred_language': 'ఇష్టపడే భాష',
162
+ 'fill_all_fields': 'దయచేసి అన్ని ఫీల్డ్‌లను పూరించండి',
163
+ 'passwords_dont_match': 'పాస్‌వర్డ్‌లు సరిపోలలేదు',
164
+ 'username_exists': 'వినియోగదారు పేరు ఇప్పటికే ఉంది',
165
+ 'registration_successful': 'నమోదు విజయవంతం! దయచేసి లాగిన్ చేయండి.',
166
+ 'invalid_credentials': 'తప్పుడు వినియోగదారు పేరు లేదా పాస్‌వర్డ్',
167
+ 'login_successful': 'లాగిన్ విజయవంతం!',
168
+ 'upload_image': 'చిత్రం అప్‌లోడ్ చేయండి',
169
+ 'choose_image': 'చిత్రాన్ని ఎంచుకోండి',
170
+ 'image_help': 'మద్దతు ఉన్న ఫార్మాట్లు: PNG, JPG, JPEG, GIF (గరిష్టంగా 10MB)',
171
+ 'image_title': 'చిత్ర శీర్షిక',
172
+ 'image_description': 'చిత్ర వివరణ',
173
+ 'native_language_label': 'మీ భాషలో లేబుల్',
174
+ 'category': 'వర్గం',
175
+ 'upload': 'అప్‌లోడ్',
176
+ 'upload_successful': 'చిత్రం విజయవంతంగా అప్‌లోడ్ అయింది!',
177
+ 'image_feed': 'చిత్ర ఫీడ్',
178
+ 'filter_by_category': 'వర్గం ద్వారా ఫిల్టర్ చేయండి',
179
+ 'all': 'అన్నీ',
180
+ 'animals': 'జంతువులు',
181
+ 'food': 'ఆహారం',
182
+ 'objects': 'వస్తువులు',
183
+ 'nature': 'ప్రకృతి',
184
+ 'people': 'వ్యక్తులు',
185
+ 'transportation': 'రవాణా',
186
+ 'labels': 'లేబుల్స్',
187
+ 'add_label': 'లేబుల్ జోడించండి',
188
+ 'new_label': 'కొత్త లేబుల్',
189
+ 'label_language': 'లేబుల్ భాష',
190
+ 'enter_label': 'దయచేసి లేబుల్ నమోదు చేయండి',
191
+ 'label_added': 'లేబుల్ విజయవంతంగా జోడించబడింది!',
192
+ 'label_exists': 'ఈ లేబుల్ ఇప్పటికే ఉంది',
193
+ 'no_images_yet': 'ఇంకా చిత్రాలు అప్‌లోడ్ చేయలేదు. మొదట పంచుకోండి!',
194
+ 'image_not_found': 'చిత్రం కనుగొనబడలేదు',
195
+ 'cancel': 'రద్దు చేయండి',
196
+ 'feed': 'ఫీడ్',
197
+ 'file_too_large': 'ఫైల్ పరిమాణం 10MB కంటే తక్కువగా ఉండాలి',
198
+ 'invalid_file_type': 'చెల్లని ఫైల్ రకం. దయచేసి PNG, JPG, JPEG, లేదా GIF ఫైల్‌లను అప్‌లోడ్ చేయండి.',
199
+ 'image_processing_error': 'చిత్ర ప్రాసెసింగ్ లోపం. దయచేసి మళ్లీ ప్రయత్నించండి.',
200
+ 'location_captured': 'స్థానం సంగ్రహించబడింది',
201
+ 'location_not_available': 'స్థానం అందుబాటులో లేదు',
202
+ 'get_location': 'స్థానం పొందండి',
203
+ 'user_details': 'వినియోగదారు వివరాలు',
204
+ 'full_name': 'పూర్తి పేరు',
205
+ 'email': 'ఇమెయిల్',
206
+ 'phone': 'ఫోన్ నంబర్',
207
+ 'age': 'వయస్సు',
208
+ 'location_info': 'స్థాన సమాచారం',
209
+ 'multilingual_image_labeling': 'బహుభాషా చిత్ర లేబలింగ్',
210
+ 'please_login': 'దయచేసి అప్లికేషన్ ఉపయోగించడం ప్రారంభించడానికి లాగిన్ చేయండి',
211
+ 'view_images': 'చిత్రాలను చూడండి',
212
+ 'please_fill_all_fields': 'దయచేసి అన్ని ఫీల్డ్‌లను పూరించండి',
213
+ 'please_fill_required_fields': 'దయచేసి అన్ని అవసరమైన ఫీల్డ్‌లను పూరించండి',
214
+ 'registration_success': 'నమోదు విజయవంతం! దయచేసి లాగిన్ చేయండి.',
215
+ 'login_success': 'లాగిన్ విజయవంతం!',
216
+ 'image_uploaded': 'చిత్రం విజయవంతంగా అప్‌లోడ్ అయింది!',
217
+ 'no_images': 'చిత్రాలు అందుబాటులో లేవు',
218
+ 'no_images_in_category': 'ఈ వర్గంలో చిత్రాలు లేవు',
219
+ 'no_labels': 'లేబుల్స్ అందుబాటులో లేవు',
220
+ 'label_text': 'లేబుల్ టెక్స్ట్'
221
+ }
222
+ }
223
+
224
+ def get_translation(key, language):
225
+ """Get translation for a specific key in the given language"""
226
+ if language in TRANSLATIONS and key in TRANSLATIONS[language]:
227
+ return TRANSLATIONS[language][key]
228
+ # Fallback to English if translation not found
229
+ return TRANSLATIONS['en'].get(key, key)
utils.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Utility functions for LabelIt! application
3
+ """
4
+
5
+ import json
6
+ import os
7
+ from PIL import Image
8
+
9
+ def load_users():
10
+ """Load users from JSON file"""
11
+ try:
12
+ with open('data/users.json', 'r') as f:
13
+ return json.load(f)
14
+ except (FileNotFoundError, json.JSONDecodeError):
15
+ return {}
16
+
17
+ def save_users(users):
18
+ """Save users to JSON file"""
19
+ with open('data/users.json', 'w') as f:
20
+ json.dump(users, f, indent=2)
21
+
22
+ def load_labels():
23
+ """Load labels from JSON file"""
24
+ try:
25
+ with open('data/labels.json', 'r') as f:
26
+ return json.load(f)
27
+ except (FileNotFoundError, json.JSONDecodeError):
28
+ return {}
29
+
30
+ def save_labels(labels):
31
+ """Save labels to JSON file"""
32
+ with open('data/labels.json', 'w') as f:
33
+ json.dump(labels, f, indent=2)
34
+
35
+ def validate_image(uploaded_file):
36
+ """Validate uploaded image file"""
37
+ # Check file size (10MB limit)
38
+ if uploaded_file.size > 10 * 1024 * 1024: # 10MB in bytes
39
+ return {
40
+ 'valid': False,
41
+ 'error': 'file_too_large'
42
+ }
43
+
44
+ # Check file type
45
+ allowed_types = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']
46
+ if uploaded_file.type not in allowed_types:
47
+ return {
48
+ 'valid': False,
49
+ 'error': 'invalid_file_type'
50
+ }
51
+
52
+ # Try to open and verify image
53
+ try:
54
+ image = Image.open(uploaded_file)
55
+ image.verify()
56
+ uploaded_file.seek(0) # Reset file pointer
57
+ return {
58
+ 'valid': True,
59
+ 'error': None
60
+ }
61
+ except Exception:
62
+ return {
63
+ 'valid': False,
64
+ 'error': 'image_processing_error'
65
+ }
66
+
67
+ def get_categories():
68
+ """Get list of available categories"""
69
+ return [
70
+ 'Animals',
71
+ 'Food',
72
+ 'Objects',
73
+ 'Nature',
74
+ 'People',
75
+ 'Transportation'
76
+ ]