Prime810 commited on
Commit
123d0c7
·
verified ·
1 Parent(s): a1abe52

Delete Frontend/static

Browse files
Frontend/static/scripts.js DELETED
@@ -1,76 +0,0 @@
1
- const video = document.querySelector("#videoElement");
2
- let currentFacingMode = "user"; // "user" = front, "environment" = back
3
- let stream = null;
4
-
5
- // Initialize camera with given facing mode
6
- function startCamera(facingMode = "user") {
7
- if (stream) {
8
- stream.getTracks().forEach(track => track.stop());
9
- }
10
-
11
- navigator.mediaDevices.getUserMedia({ video: { facingMode } })
12
- .then((newStream) => {
13
- stream = newStream;
14
- video.srcObject = stream;
15
- })
16
- .catch((err) => {
17
- console.error("Error accessing camera: ", err);
18
- alert("Camera access failed. Please allow camera permissions.");
19
- });
20
- }
21
-
22
- // Flip between front and back camera
23
- function toggleCamera() {
24
- currentFacingMode = currentFacingMode === "user" ? "environment" : "user";
25
- startCamera(currentFacingMode);
26
- }
27
-
28
- // Capture current frame from video, show it, and send to backend
29
- function captureAndSend() {
30
- if (!stream) {
31
- alert("Camera is not started yet!");
32
- return;
33
- }
34
-
35
- // Create a canvas to capture the frame
36
- const canvas = document.createElement('canvas');
37
- canvas.width = video.videoWidth;
38
- canvas.height = video.videoHeight;
39
-
40
- const context = canvas.getContext('2d');
41
- context.drawImage(video, 0, 0, canvas.width, canvas.height);
42
-
43
- // Convert canvas to data URL (JPEG)
44
- const dataUrl = canvas.toDataURL("image/jpeg");
45
-
46
- // Show captured image preview in <img>
47
- document.getElementById("snapshotImage").src = dataUrl;
48
-
49
- // Send captured image to backend
50
- fetch("https://prime810-facefeel.hf.space/process_image", {
51
- method: "POST",
52
- headers: { "Content-Type": "application/json" },
53
- body: JSON.stringify({ image: dataUrl })
54
- })
55
- .then(response => response.json())
56
- .then(data => {
57
- // Display returned emoji and emotion
58
- document.getElementById("emojiDisplay").innerHTML =
59
- <img src="${data.emoji}" style="width:200px; border-radius:10px;">;
60
- document.getElementById("emotionText").textContent =
61
- Emotion: ${data.emotion};
62
- // Show download button for emoji image
63
- const link = document.getElementById("downloadEmoji");
64
- link.href = data.emoji;
65
- link.style.display = "inline-block";
66
- // Play emoji sound if available
67
- const sound = document.getElementById("emojiSound");
68
- if (sound) sound.play();
69
- })
70
- .catch(error => {
71
- console.error("Error:", error);
72
- alert("Failed to get emoji. Is your backend running?");
73
- });
74
- }
75
- // Start camera automatically on page load
76
- startCamera();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Frontend/static/style.css DELETED
@@ -1,116 +0,0 @@
1
- body {
2
- margin: 0;
3
- font-family: 'Segoe UI', sans-serif;
4
- background: linear-gradient(to bottom right, #141e30, #243b55);
5
- color: #f3f3f3;
6
- text-align: center;
7
- }
8
-
9
- header {
10
- padding: 2rem 1rem;
11
- background: linear-gradient(to right, #ff9a9e, #fad0c4);
12
- color: transparent;
13
- -webkit-background-clip: text;
14
- background-clip: text;
15
- }
16
-
17
- header h1 {
18
- font-size: 3rem;
19
- margin: 0;
20
- }
21
-
22
- header p {
23
- font-size: 1.2rem;
24
- margin-top: 0.5rem;
25
- }
26
-
27
- .camera-section {
28
- padding: 1rem;
29
- }
30
-
31
- #videoElement {
32
- width: 100%;
33
- max-width: 460px;
34
- border-radius: 20px;
35
- border: 4px solid rgba(255, 255, 255, 0.3);
36
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
37
- object-fit: cover;
38
- margin-bottom: 1rem;
39
- }
40
-
41
- .btn-group {
42
- margin-top: 1rem;
43
- }
44
-
45
- .btn {
46
- background: linear-gradient(to right, #6a11cb, #2575fc);
47
- color: white;
48
- padding: 12px 24px;
49
- border: none;
50
- border-radius: 40px;
51
- font-size: 1rem;
52
- font-weight: bold;
53
- margin: 8px;
54
- cursor: pointer;
55
- transition: all 0.3s ease;
56
- box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
57
- }
58
-
59
- .btn:hover {
60
- background: linear-gradient(to right, #43e97b, #38f9d7);
61
- transform: scale(1.05);
62
- }
63
-
64
- .result-section {
65
- padding: 1rem;
66
- }
67
-
68
- #capturedImagePreview img {
69
- width: 100%;
70
- max-width: 360px;
71
- margin-top: 1rem;
72
- border-radius: 16px;
73
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
74
- }
75
-
76
- #emojiDisplay img {
77
- margin-top: 1rem;
78
- width: 100px;
79
- animation: bounce 1.2s ease-in-out infinite;
80
- }
81
-
82
- #emotionText {
83
- margin-top: 1rem;
84
- font-size: 1.3rem;
85
- font-weight: 500;
86
- color: #c7ffec;
87
- }
88
-
89
- #downloadEmoji {
90
- display: inline-block;
91
- margin-top: 1rem;
92
- background: linear-gradient(to right, #ee0979, #ff6a00);
93
- padding: 12px 24px;
94
- border-radius: 30px;
95
- color: white;
96
- text-decoration: none;
97
- font-weight: bold;
98
- transition: 0.3s;
99
- }
100
-
101
- #downloadEmoji:hover {
102
- transform: scale(1.05);
103
- box-shadow: 0 8px 16px rgba(238, 9, 121, 0.3);
104
- }
105
-
106
- footer {
107
- margin-top: 2rem;
108
- padding: 1rem;
109
- font-size: 0.9rem;
110
- color: #aaa;
111
- }
112
-
113
- @keyframes bounce {
114
- 0%, 100% { transform: translateY(0); }
115
- 50% { transform: translate(-10px); }
116
- }