Skip to content

Commit 957b529

Browse files
committed
the AI file path from ../AI in AI
2 parents 14137d1 + f562757 commit 957b529

File tree

9 files changed

+66
-36
lines changed

9 files changed

+66
-36
lines changed

AI/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def classify_image_huggingface(image_opencv):
5252
return result
5353

5454

55-
base_options = python.BaseOptions(model_asset_path='../AI/training/gesture_recognizer_trained_large_dataset.task')
55+
base_options = python.BaseOptions(model_asset_path='./AI/training/recent_data_gesture_recognizer.task')
5656
options = vision.GestureRecognizerOptions(base_options=base_options)
5757
recognizer = vision.GestureRecognizer.create_from_options(options)
5858
def classify_image(image_opencv):
@@ -62,14 +62,14 @@ def classify_image(image_opencv):
6262

6363

6464
if __name__ == '__main__':
65-
print(call_openai_model("HHhhhhheeeelllllloooooo"))
66-
# cap = cv2.VideoCapture(0)
67-
# w, h = 360, 240
68-
# while True:
69-
# _, img = cap.read()
70-
# img = cv2.resize(img, (w,h))
71-
# cv2.imshow("Camera",img)
72-
# if cv2.waitKey(1) & 0xFF == ord('q'):
73-
# break
74-
# print(classify_image(img))
65+
# print(call_openai_model("HHhhhhheeeelllllloooooo"))
66+
cap = cv2.VideoCapture(0)
67+
w, h = 360, 240
68+
while True:
69+
_, img = cap.read()
70+
img = cv2.resize(img, (w,h))
71+
cv2.imshow("Camera",img)
72+
if cv2.waitKey(1) & 0xFF == ord('q'):
73+
break
74+
print(classify_image(img))
7575

8.09 MB
Binary file not shown.

AI/training/script.txt

Whitespace-only changes.

AI/training/script2.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Set the directory where you want to start
2+
$startDirectory = "C:\Path\To\Your\Directory"
3+
4+
# Get all files recursively
5+
Get-ChildItem -Path $startDirectory -Recurse -File | ForEach-Object {
6+
$filePath = $_.FullName
7+
$directory = $_.DirectoryName
8+
$newName = "a" + $_.Name # Add 'a' at the start of the file name (modify as needed)
9+
$newPath = Join-Path -Path $directory -ChildPath $newName
10+
11+
# Rename the file
12+
Rename-Item -Path $filePath -NewName $newPath
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
training data (curated):
2+
3+
4+
5+
sources:
16
https://www.cvssp.org/FingerSpellingKinect2011/fingerspelling5.tar.bz2
27
https://www.cvssp.org/FingerSpellingKinect2011/dataset9-depth.tar.gz
8+
https://www.kaggle.com/datasets/grassknoted/asl-alphabet/data

backend/server.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,23 @@ def translate():
7575
if image_opencv is None:
7676
return jsonify({'error': f'Could not read image: {filename}'}), 400
7777

78-
translation_result = ai.classify_image_huggingface(image_opencv)
79-
print(translation_result)
78+
# translation_result = ai.classify_image_huggingface(image_opencv)
79+
# print(translation_result)
8080

81-
# translation_result = ai.classify_image(image_opencv)
82-
# if translation_result:
83-
# all_translations.append(translation_result[0][0].category_name)
84-
# if translation_result:
85-
# print(translation_result[0][0].category_name)
81+
translation_result = ai.classify_image(image_opencv)
82+
if translation_result:
83+
all_translations.append(translation_result[0][0].category_name)
84+
if translation_result:
85+
print(translation_result[0][0].category_name)
8686

8787
os.remove(file_path)
8888

89-
# translation_string = ' '.join(all_translations)
90-
# final_translation = ai.call_openai_model(translation_string)
91-
# print(final_translation.content)
89+
translation_string = ''.join(all_translations)
90+
final_translation = ai.call_openai_model(translation_string)
91+
print(final_translation.content)
9292

9393
return jsonify({
94-
# 'translation': final_translation.content
94+
'translation': final_translation.content
9595
}), 200
9696

9797
if __name__ == '__main__':

sign_language_translator/lib/camera_page.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import 'package:sign_language_translator/components/camera.dart';
33
import 'package:sign_language_translator/components/instructions_pop_up.dart';
44

55
class CameraPage extends StatefulWidget {
6-
const CameraPage({
7-
super.key,
8-
});
6+
const CameraPage({super.key});
97

108
@override
119
State<CameraPage> createState() => _CameraPageState();
@@ -14,6 +12,13 @@ class CameraPage extends StatefulWidget {
1412
class _CameraPageState extends State<CameraPage> {
1513
final GlobalKey<CameraState> _cameraKey = GlobalKey<CameraState>();
1614
bool _isTranslating = false;
15+
String _translation = '';
16+
17+
void _updateTranslation(String translation) {
18+
setState(() {
19+
_translation = translation;
20+
});
21+
}
1722

1823
@override
1924
Widget build(BuildContext context) {
@@ -34,7 +39,10 @@ class _CameraPageState extends State<CameraPage> {
3439
const SizedBox(height: 2),
3540
Container(
3641
constraints: const BoxConstraints(maxHeight: 400),
37-
child: Camera(key: _cameraKey),
42+
child: Camera(
43+
key: _cameraKey,
44+
onTranslationReceived: _updateTranslation,
45+
),
3846
),
3947
const SizedBox(height: 110),
4048
Column(
@@ -46,8 +54,7 @@ class _CameraPageState extends State<CameraPage> {
4654
onPressed: () {
4755
setState(() {
4856
if (_isTranslating) {
49-
_cameraKey.currentState
50-
?.stopAndGetTranslation();
57+
_cameraKey.currentState?.stopAndGetTranslation();
5158
} else {
5259
_cameraKey.currentState?.startTakingPictures();
5360
}
@@ -76,9 +83,9 @@ class _CameraPageState extends State<CameraPage> {
7683
padding: const EdgeInsets.symmetric(horizontal: 20),
7784
height: 92,
7885
alignment: Alignment.center,
79-
child: const Text(
80-
'Sign Language Translator',
81-
style: TextStyle(
86+
child: Text(
87+
_translation.isEmpty ? 'No translation' : _translation,
88+
style: const TextStyle(
8289
color: Colors.deepPurple,
8390
fontSize: 20,
8491
),

sign_language_translator/lib/components/camera.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import 'package:flutter/material.dart';
44
import 'package:sign_language_translator/services/network.dart';
55

66
class Camera extends StatefulWidget {
7-
const Camera({super.key});
7+
final Function(String) onTranslationReceived;
8+
9+
const Camera({super.key, required this.onTranslationReceived});
810

911
@override
1012
State<Camera> createState() => CameraState();
@@ -152,8 +154,10 @@ class CameraState extends State<Camera> {
152154
// asigura ca se opreste upload-ul
153155
await Future.delayed(const Duration(milliseconds: 50));
154156

155-
return network.getTranslation();
156-
}
157+
String translation = await network.getTranslation();
157158

158-
List<String> translationOutputs = [];
159+
widget.onTranslationReceived(translation);
160+
161+
return translation;
162+
}
159163
}

sign_language_translator/lib/services/network.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Network {
4646
}
4747
} catch (e) {
4848
print('Eroare: $e');
49-
return "Error transalting your message";
49+
return "Error translating your message";
5050
}
5151
return "";
5252
}

0 commit comments

Comments
 (0)