Ukrainian
Ihorog commited on
Commit
12d960f
·
verified ·
1 Parent(s): 7ef2f47

Upload 7 files

Browse files
Files changed (7) hide show
  1. deploy.ps1 +138 -0
  2. desktop.ini +4 -0
  3. image.py +46 -0
  4. index.py +38 -0
  5. mer.html +127 -0
  6. styles.css +68 -0
  7. tailwind.config.js +11 -0
deploy.ps1 ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Скрипт для автоматичної установки і запуску проекту (Backend + Frontend)
2
+
3
+ # 1. Встановлення Python та FastAPI
4
+ Write-Host "Встановлення Python та FastAPI..."
5
+ if (-Not (Get-Command python -ErrorAction SilentlyContinue)) {
6
+ Write-Host "Python не знайдено, встановлення..."
7
+ Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.9.7/python-3.9.7-amd64.exe" -OutFile "python-installer.exe"
8
+ Start-Process -FilePath "python-installer.exe" -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1" -Wait
9
+ }
10
+ Write-Host "Перевірка встановлення Python..."
11
+ python --version
12
+
13
+ Write-Host "Встановлення FastAPI та залежностей..."
14
+ pip install fastapi uvicorn pillow websockets transformers torch aiofiles
15
+
16
+ # 2. Встановлення Node.js та React
17
+ Write-Host "Встановлення Node.js та NPM..."
18
+ if (-Not (Get-Command npm -ErrorAction SilentlyContinue)) {
19
+ Write-Host "Node.js не знайдено, встановлення..."
20
+ Invoke-WebRequest -Uri "https://nodejs.org/dist/v14.17.0/node-v14.17.0-x64.msi" -OutFile "nodejs-installer.msi"
21
+ Start-Process -FilePath "nodejs-installer.msi" -ArgumentList "/quiet" -Wait
22
+ }
23
+ Write-Host "Перевірка встановлення Node.js..."
24
+ node --version
25
+ npm --version
26
+
27
+ # 3. Налаштування React з Tailwind CSS
28
+ Write-Host "Налаштування фронтенду (React + Tailwind CSS)..."
29
+ if (-Not (Test-Path "frontend")) {
30
+ Write-Host "Створення нового React проекту..."
31
+ npx create-react-app frontend
32
+ }
33
+
34
+ cd frontend
35
+ npm install tailwindcss
36
+ npx tailwindcss init
37
+
38
+ # Налаштування Tailwind у React проекті
39
+ Write-Host "Налаштування Tailwind CSS..."
40
+ Set-Content -Path ".\src\index.css" -Value "@tailwind base;`n@tailwind components;`n@tailwind utilities;"
41
+
42
+ # Налаштування Tailwind конфігурації
43
+ Set-Content -Path ".\tailwind.config.js" -Value @"
44
+ module.exports = {
45
+ purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
46
+ darkMode: false,
47
+ theme: {
48
+ extend: {},
49
+ },
50
+ variants: {
51
+ extend: {},
52
+ },
53
+ plugins: [],
54
+ }
55
+ "@
56
+
57
+ # Повернення в кореневу директорію
58
+ cd ..
59
+
60
+ # 4. Створення backend API з FastAPI
61
+ Write-Host "Створення backend API (FastAPI)..."
62
+ Set-Content -Path "app.py" -Value @"
63
+ from fastapi import FastAPI, UploadFile
64
+ from PIL import Image, ImageDraw, ImageFont
65
+ from io import BytesIO
66
+ import random
67
+ import websockets
68
+ import asyncio
69
+
70
+ app = FastAPI()
71
+
72
+ # Генерація фону
73
+ @app.get("/api/generate-background")
74
+ async def generate_background():
75
+ width, height = 800, 600
76
+ image = Image.new('RGB', (width, height), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
77
+
78
+ draw = ImageDraw.Draw(image)
79
+ font = ImageFont.load_default()
80
+ draw.text((width // 4, height // 2), 'Your Dynamic Background', font=font, fill=(255, 255, 255))
81
+
82
+ buffer = BytesIO()
83
+ image.save(buffer, format='PNG')
84
+ buffer.seek(0)
85
+
86
+ background_path = 'static/background.png'
87
+ with open(background_path, 'wb') as f:
88
+ f.write(buffer.getvalue())
89
+
90
+ return {'backgroundUrl': background_path}
91
+
92
+ # Завантаження зображення
93
+ @app.post("/upload")
94
+ async def upload_image(file: UploadFile):
95
+ contents = await file.read()
96
+ image = Image.open(BytesIO(contents))
97
+ image.save(f"uploads/{file.filename}")
98
+
99
+ caption = f"Your generated caption for {file.filename}"
100
+
101
+ return {"caption": caption}
102
+ "@
103
+
104
+ # 5. WebSocket сервер
105
+ Write-Host "Створення WebSocket сервера..."
106
+ Set-Content -Path "ws_server.py" -Value @"
107
+ import asyncio
108
+ import websockets
109
+
110
+ connected_clients = set()
111
+
112
+ async def handler(websocket):
113
+ connected_clients.add(websocket)
114
+ try:
115
+ async for message in websocket:
116
+ for client in connected_clients:
117
+ if client != websocket:
118
+ await client.send(message)
119
+ finally:
120
+ connected_clients.remove(websocket)
121
+
122
+ start_server = websockets.serve(handler, 'localhost', 8765)
123
+
124
+ asyncio.get_event_loop().run_until_complete(start_server)
125
+ asyncio.get_event_loop().run_forever()
126
+ "@
127
+
128
+ # 6. Запуск проекту
129
+ Write-Host "Запуск FastAPI серверу..."
130
+ Start-Process -NoNewWindow -FilePath "python" -ArgumentList "app.py"
131
+
132
+ Write-Host "Запуск WebSocket серверу..."
133
+ Start-Process -NoNewWindow -FilePath "python" -ArgumentList "ws_server.py"
134
+
135
+ # Запуск React фронтенду
136
+ cd frontend
137
+ Write-Host "Запуск React фронтенду..."
138
+ npm start
desktop.ini ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ViewState]
2
+ Mode=
3
+ Vid=
4
+ FolderType=StorageProviderGeneric
image.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import numpy as np
4
+ from skimage import feature
5
+
6
+ # Функція для завантаження зображень з директорії
7
+ def load_images_from_folder(folder):
8
+ images = []
9
+ for filename in os.listdir(folder):
10
+ img = cv2.imread(os.path.join(folder, filename))
11
+ if img is not None:
12
+ images.append((filename, img))
13
+ return images
14
+
15
+ # Функція для оцінки якості зображення
16
+ def evaluate_image_quality(image):
17
+ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
18
+ laplacian_var = cv2.Laplacian(gray, cv2.CV_64F).var()
19
+ return laplacian_var
20
+
21
+ # Функція для оцінки цікавості зображення
22
+ def evaluate_image_interest(image):
23
+ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
24
+ edges = feature.canny(gray)
25
+ return np.sum(edges)
26
+
27
+ # Основна функція для відбору зображень
28
+ def select_best_images(folder, quality_threshold=100, interest_threshold=1000):
29
+ images = load_images_from_folder(folder)
30
+ selected_images = []
31
+
32
+ for filename, img in images:
33
+ quality_score = evaluate_image_quality(img)
34
+ interest_score = evaluate_image_interest(img)
35
+
36
+ if quality_score > quality_threshold and interest_score > interest_threshold:
37
+ selected_images.append((filename, img, quality_score, interest_score))
38
+
39
+ return selected_images
40
+
41
+ # Виклик основної функції
42
+ folder = r'C:\Users\simei\OneDrive\Робочий стіл\mer'
43
+ best_images = select_best_images(folder)
44
+
45
+ for filename, img, quality, interest in best_images:
46
+ print(f"Selected {filename} with quality score {quality} and interest score {interest}")
index.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
2
+ from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, MessageHandler, Filters
3
+
4
+ # Функція старту
5
+ def start(update, context):
6
+ update.message.reply_text(
7
+ "Вітаю! Я ваш чат-бот для навігації по альбому. Оберіть опцію:",
8
+ reply_markup=main_menu_keyboard()
9
+ )
10
+
11
+ # Головне меню
12
+ def main_menu_keyboard():
13
+ keyboard = [[InlineKeyboardButton('Фотографії', callback_data='photos')],
14
+ [InlineKeyboardButton('Відео', callback_data='videos')],
15
+ [InlineKeyboardButton('Аудіо', callback_data='audio')]]
16
+ return InlineKeyboardMarkup(keyboard)
17
+
18
+ # Обробка вибору
19
+ def main_menu(update, context):
20
+ query = update.callback_query
21
+ query.answer()
22
+ query.edit_message_text(
23
+ text="Оберіть опцію:",
24
+ reply_markup=main_menu_keyboard()
25
+ )
26
+
27
+ # Функції для обробки вибору
28
+ def photos(update, context):
29
+ query = update.callback_query
30
+ query.answer()
31
+ query.edit_message_text(text="Ось ваші фотографії: Посилання на галерею")
32
+
33
+ def videos(update, context):
34
+ query = update.callback_query
35
+ query.answer()
36
+ query.edit_message_text(text="Ось ваші відео: Посилання на відео")
37
+
38
+ def audio
mer.html ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="uk">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Наша Історія</title>
7
+ <link rel="stylesheet" href="styles.css">
8
+ <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
9
+ <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
10
+ </head>
11
+ <body>
12
+ <header>
13
+ <h1>Наша Історія</h1>
14
+ <p>Сім розділів нашого життя, наповнені емоціями та спогадами</p>
15
+ </header>
16
+
17
+ <main>
18
+ <section class="menu">
19
+ <h2>Обери розділ:</h2>
20
+ <ul>
21
+ <li><a href="#section1">1. А якщо</a></li>
22
+ <li><a href="#section2">2. Разом</a></li>
23
+ <li><a href="#section3">3. Любити</a></li>
24
+ <li><a href="#section4">4. Життя</a></li>
25
+ <li><a href="#section5">5. По справжньому</a></li>
26
+ <li><a href="#section6">6. Радіти</a></li>
27
+ <li><a href="#section7">7. Мріяти</a></li>
28
+ </ul>
29
+ </section>
30
+
31
+ <!-- Розділи -->
32
+ <!-- Розділ 1: А якщо -->
33
+ <section id="section1" class="content">
34
+ <h2>1. А якщо</h2>
35
+ <div class="media">
36
+ <h3>Фотогалерея:</h3>
37
+ <div class="swiper-container">
38
+ <div class="swiper-wrapper">
39
+ <div class="swiper-slide"><img src="images/photo1.jpg" alt="Фото 1"></div>
40
+ <div class="swiper-slide"><img src="images/photo2.jpg" alt="Фото 2"></div>
41
+ </div>
42
+ <div class="swiper-pagination"></div>
43
+ <div class="swiper-button-next"></div>
44
+ <div class="swiper-button-prev"></div>
45
+ </div>
46
+
47
+ <h3>Відео:</h3>
48
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/YOUR_VIDEO_ID" frameborder="0" allowfullscreen></iframe>
49
+
50
+ <h3>Аудіо:</h3>
51
+ <audio controls>
52
+ <source src="audio/wedding-audio1.mp3" type="audio/mpeg">
53
+ Ваш браузер не підтримує аудіо.
54
+ </audio>
55
+ </div>
56
+ </section>
57
+
58
+ <!-- Розділ 2: Разом -->
59
+ <section id="section2" class="content">
60
+ <h2>2. Разом</h2>
61
+ <div class="media">
62
+ <h3>Фотогалерея:</h3>
63
+ <div class="swiper-container">
64
+ <div class="swiper-wrapper">
65
+ <div class="swiper-slide"><img src="images/photo3.jpg" alt="Фото 3"></div>
66
+ <div class="swiper-slide"><img src="images/photo4.jpg" alt="Фото 4"></div>
67
+ </div>
68
+ <div class="swiper-pagination"></div>
69
+ <div class="swiper-button-next"></div>
70
+ <div class="swiper-button-prev"></div>
71
+ </div>
72
+
73
+ <h3>Відео:</h3>
74
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/YOUR_VIDEO_ID_2" frameborder="0" allowfullscreen></iframe>
75
+
76
+ <h3>Аудіо:</h3>
77
+ <audio controls>
78
+ <source src="audio/wedding-audio2.mp3" type="audio/mpeg">
79
+ Ваш браузер не підтримує аудіо.
80
+ </audio>
81
+ </div>
82
+ </section>
83
+
84
+ <!-- Розділ 3: Любити -->
85
+ <section id="section3" class="content">
86
+ <h2>3. Любити</h2>
87
+ <div class="media">
88
+ <h3>Фотогалерея:</h3>
89
+ <div class="swiper-container">
90
+ <div class="swiper-wrapper">
91
+ <div class="swiper-slide"><img src="images/photo5.jpg" alt="Фото 5"></div>
92
+ <div class="swiper-slide"><img src="images/photo6.jpg" alt="Фото 6"></div>
93
+ </div>
94
+ <div class="swiper-pagination"></div>
95
+ <div class="swiper-button-next"></div>
96
+ <div class="swiper-button-prev"></div>
97
+ </div>
98
+
99
+ <h3>Відео:</h3>
100
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/YOUR_VIDEO_ID_3" frameborder="0" allowfullscreen></iframe>
101
+
102
+ <h3>Аудіо:</h3>
103
+ <audio controls>
104
+ <source src="audio/wedding-audio3.mp3" type="audio/mpeg">
105
+ Ваш браузер не підтримує аудіо.
106
+ </audio>
107
+ </div>
108
+ </section>
109
+
110
+ <!-- Дод��йте інші розділи аналогічно -->
111
+
112
+ </main>
113
+
114
+ <script>
115
+ var swiper = new Swiper('.swiper-container', {
116
+ navigation: {
117
+ nextEl: '.swiper-button-next',
118
+ prevEl: '.swiper-button-prev',
119
+ },
120
+ pagination: {
121
+ el: '.swiper-pagination',
122
+ clickable: true,
123
+ },
124
+ });
125
+ </script>
126
+ </body>
127
+ </html>
styles.css ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ margin: 0;
4
+ padding: 0;
5
+ background-color: #f4f4f4;
6
+ }
7
+
8
+ header {
9
+ background-color: #333;
10
+ color: #fff;
11
+ padding: 20px 0;
12
+ text-align: center;
13
+ }
14
+
15
+ header h1 {
16
+ margin: 0;
17
+ font-size: 2.5em;
18
+ }
19
+
20
+ header p {
21
+ margin: 0;
22
+ font-size: 1.2em;
23
+ }
24
+
25
+ .menu {
26
+ background-color: #fff;
27
+ padding: 20px;
28
+ text-align: center;
29
+ }
30
+
31
+ .menu h2 {
32
+ margin-top: 0;
33
+ }
34
+
35
+ .menu ul {
36
+ list-style: none;
37
+ padding: 0;
38
+ }
39
+
40
+ .menu ul li {
41
+ display: inline;
42
+ margin: 0 10px;
43
+ }
44
+
45
+ .menu ul li a {
46
+ color: #333;
47
+ text-decoration: none;
48
+ font-size: 1.2em;
49
+ }
50
+
51
+ .content {
52
+ padding: 20px;
53
+ text-align: center;
54
+ }
55
+
56
+ .media {
57
+ margin-top: 20px;
58
+ }
59
+
60
+ footer {
61
+ background-color: #333;
62
+ color: #fff;
63
+ text-align: center;
64
+ padding: 10px 0;
65
+ position: fixed;
66
+ width: 100%;
67
+ bottom: 0;
68
+ }
tailwind.config.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = {
2
+ purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
3
+ darkMode: false,
4
+ theme: {
5
+ extend: {},
6
+ },
7
+ variants: {
8
+ extend: {},
9
+ },
10
+ plugins: [],
11
+ }