bilal-visionapp 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bilal_visionapp-1.0.0/PKG-INFO +14 -0
- bilal_visionapp-1.0.0/pyproject.toml +26 -0
- bilal_visionapp-1.0.0/setup.cfg +4 -0
- bilal_visionapp-1.0.0/src/bilal_visionapp.egg-info/PKG-INFO +14 -0
- bilal_visionapp-1.0.0/src/bilal_visionapp.egg-info/SOURCES.txt +9 -0
- bilal_visionapp-1.0.0/src/bilal_visionapp.egg-info/dependency_links.txt +1 -0
- bilal_visionapp-1.0.0/src/bilal_visionapp.egg-info/entry_points.txt +2 -0
- bilal_visionapp-1.0.0/src/bilal_visionapp.egg-info/requires.txt +8 -0
- bilal_visionapp-1.0.0/src/bilal_visionapp.egg-info/top_level.txt +1 -0
- bilal_visionapp-1.0.0/src/visionapp/__init__.py +0 -0
- bilal_visionapp-1.0.0/src/visionapp/main.py +130 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bilal-visionapp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Ein 100% lokales KI Vision System fuer PC und Smartphone
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: ultralytics
|
|
8
|
+
Requires-Dist: transformers
|
|
9
|
+
Requires-Dist: torch
|
|
10
|
+
Requires-Dist: torchvision
|
|
11
|
+
Requires-Dist: opencv-python
|
|
12
|
+
Requires-Dist: Pillow
|
|
13
|
+
Requires-Dist: pyttsx3
|
|
14
|
+
Requires-Dist: Flask
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "bilal-visionapp"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Ein 100% lokales KI Vision System fuer PC und Smartphone"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"ultralytics",
|
|
13
|
+
"transformers",
|
|
14
|
+
"torch",
|
|
15
|
+
"torchvision",
|
|
16
|
+
"opencv-python",
|
|
17
|
+
"Pillow",
|
|
18
|
+
"pyttsx3",
|
|
19
|
+
"Flask"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
visionapp = "visionapp.main:cli"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
where = ["src"]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bilal-visionapp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Ein 100% lokales KI Vision System fuer PC und Smartphone
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: ultralytics
|
|
8
|
+
Requires-Dist: transformers
|
|
9
|
+
Requires-Dist: torch
|
|
10
|
+
Requires-Dist: torchvision
|
|
11
|
+
Requires-Dist: opencv-python
|
|
12
|
+
Requires-Dist: Pillow
|
|
13
|
+
Requires-Dist: pyttsx3
|
|
14
|
+
Requires-Dist: Flask
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
src/bilal_visionapp.egg-info/PKG-INFO
|
|
3
|
+
src/bilal_visionapp.egg-info/SOURCES.txt
|
|
4
|
+
src/bilal_visionapp.egg-info/dependency_links.txt
|
|
5
|
+
src/bilal_visionapp.egg-info/entry_points.txt
|
|
6
|
+
src/bilal_visionapp.egg-info/requires.txt
|
|
7
|
+
src/bilal_visionapp.egg-info/top_level.txt
|
|
8
|
+
src/visionapp/__init__.py
|
|
9
|
+
src/visionapp/main.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
visionapp
|
|
File without changes
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import argparse
|
|
4
|
+
import cv2
|
|
5
|
+
import time
|
|
6
|
+
import io
|
|
7
|
+
import base64
|
|
8
|
+
import threading
|
|
9
|
+
from PIL import Image, ImageTk
|
|
10
|
+
import tkinter as tk
|
|
11
|
+
import pyttsx3
|
|
12
|
+
from ultralytics import YOLO
|
|
13
|
+
from transformers import BlipProcessor, BlipForConditionalGeneration
|
|
14
|
+
|
|
15
|
+
# KIs global laden
|
|
16
|
+
print("⏳ Lade KIs lokal... Bitte warten...")
|
|
17
|
+
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
|
18
|
+
blip_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
|
19
|
+
model = YOLO("yolov8n.pt")
|
|
20
|
+
print("✅ KIs einsatzbereit!")
|
|
21
|
+
|
|
22
|
+
# Sprachausgabe
|
|
23
|
+
try:
|
|
24
|
+
engine = pyttsx3.init()
|
|
25
|
+
engine.setProperty('rate', 145)
|
|
26
|
+
except:
|
|
27
|
+
engine = None
|
|
28
|
+
|
|
29
|
+
def speak(text):
|
|
30
|
+
if engine:
|
|
31
|
+
def run():
|
|
32
|
+
engine.say(text)
|
|
33
|
+
engine.runAndWait()
|
|
34
|
+
threading.Thread(target=run, daemon=True).start()
|
|
35
|
+
|
|
36
|
+
# --- PC MODUS (Tkinter GUI) ---
|
|
37
|
+
class LocalSuperVisionApp:
|
|
38
|
+
def __init__(self, window):
|
|
39
|
+
self.window = window
|
|
40
|
+
self.window.title("KI Vision Pro - PC Modus")
|
|
41
|
+
self.window.geometry("850x680")
|
|
42
|
+
self.window.configure(bg="#1e272e")
|
|
43
|
+
self.vid = cv2.VideoCapture(0)
|
|
44
|
+
self.canvas = tk.Canvas(window, width=640, height=480, bg="#2f3640", highlightthickness=0)
|
|
45
|
+
self.canvas.pack(pady=15)
|
|
46
|
+
self.btn = tk.Button(window, text="📸 LOKALER SUPER-SCAN", command=self.snapshot, bg="#4cd137", fg="white", font=("Arial", 12, "bold"))
|
|
47
|
+
self.btn.pack(pady=5)
|
|
48
|
+
self.lbl = tk.Label(window, text="Status: Bereit.", font=("Arial", 11, "bold"), fg="#f5f6fa", bg="#1e272e")
|
|
49
|
+
self.lbl.pack(pady=10)
|
|
50
|
+
self.update_webcam()
|
|
51
|
+
|
|
52
|
+
def update_webcam(self):
|
|
53
|
+
ret, frame = self.vid.read()
|
|
54
|
+
if ret:
|
|
55
|
+
frame = cv2.flip(frame, 1)
|
|
56
|
+
self.current_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
|
57
|
+
self.photo = ImageTk.PhotoImage(image=Image.fromarray(self.current_frame))
|
|
58
|
+
self.canvas.create_image(0, 0, image=self.photo, anchor=tk.NW)
|
|
59
|
+
self.window.after(15, self.update_webcam)
|
|
60
|
+
|
|
61
|
+
def snapshot(self):
|
|
62
|
+
ret, frame = self.vid.read()
|
|
63
|
+
if ret:
|
|
64
|
+
frame = cv2.flip(frame, 1)
|
|
65
|
+
results = model(frame, conf=0.45)
|
|
66
|
+
annotated_frame = results[0].plot()
|
|
67
|
+
img_rgb = cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB)
|
|
68
|
+
self.photo = ImageTk.PhotoImage(image=Image.fromarray(img_rgb))
|
|
69
|
+
self.canvas.create_image(0, 0, image=self.photo, anchor=tk.NW)
|
|
70
|
+
|
|
71
|
+
def run_blip():
|
|
72
|
+
inputs = processor(Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)), return_tensors="pt")
|
|
73
|
+
out = blip_model.generate(**inputs)
|
|
74
|
+
caption = processor.decode(out, skip_special_tokens=True)
|
|
75
|
+
self.lbl.config(text=f"KI sieht: {caption}", fg="#00a8ff")
|
|
76
|
+
speak(caption)
|
|
77
|
+
threading.Thread(target=run_blip).start()
|
|
78
|
+
|
|
79
|
+
# --- HANDY MODUS (Flask Webserver) ---
|
|
80
|
+
def run_phone_mode():
|
|
81
|
+
from flask import Flask, render_template_string, Response, jsonify
|
|
82
|
+
import numpy as np
|
|
83
|
+
|
|
84
|
+
flask_app = Flask(__name__)
|
|
85
|
+
video_capture = cv2.VideoCapture(0)
|
|
86
|
+
latest_frame = [None]
|
|
87
|
+
|
|
88
|
+
def gen_frames():
|
|
89
|
+
while True:
|
|
90
|
+
success, frame = video_capture.read()
|
|
91
|
+
if not success: break
|
|
92
|
+
frame = cv2.flip(frame, 1)
|
|
93
|
+
latest_frame[0] = frame.copy()
|
|
94
|
+
ret, buffer = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 80])
|
|
95
|
+
yield (b'--frame\r\nContent-Type: image/jpeg\r\n\r\n' + buffer.tobytes() + b'\r\n')
|
|
96
|
+
|
|
97
|
+
@flask_app.route('/')
|
|
98
|
+
def idx():
|
|
99
|
+
return "<h1>💻 Laptop-Live-KI</h1><img src='/feed' style='width:100%;max-width:600px;'><br><button onclick='scan()'>SCAN</button><div id='r'></div><script>function scan(){ fetch('/scan', {method:'POST'}).then(r=>r.json()).then(d=>{document.getElementById('r').innerText=d.c; window.speechSynthesis.speak(new SpeechSynthesisUtterance(d.c));})}</script>"
|
|
100
|
+
|
|
101
|
+
@flask_app.route('/feed')
|
|
102
|
+
def feed(): return Response(gen_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
|
|
103
|
+
|
|
104
|
+
@flask_app.route('/scan', methods=['POST'])
|
|
105
|
+
def scan():
|
|
106
|
+
if latest_frame[0] is None: return jsonify({'c': 'No image'})
|
|
107
|
+
inputs = processor(Image.fromarray(cv2.cvtColor(latest_frame[0], cv2.COLOR_BGR2RGB)), return_tensors="pt")
|
|
108
|
+
out = blip_model.generate(**inputs)
|
|
109
|
+
return jsonify({'c': processor.decode(out, skip_special_tokens=True)})
|
|
110
|
+
|
|
111
|
+
import socket
|
|
112
|
+
ip = socket.gethostbyname(socket.gethostname())
|
|
113
|
+
print(f"📱 ÖFFNE AUF DEINEM HANDY: http://{ip}:5000")
|
|
114
|
+
flask_app.run(host='0.0.0.0', port=5000)
|
|
115
|
+
|
|
116
|
+
# --- ENTRYPOINT (Befehlssteuerung) ---
|
|
117
|
+
def cli():
|
|
118
|
+
parser = argparse.ArgumentParser(description="KI Vision App")
|
|
119
|
+
parser.add_argument('--mode', choices=['pc', 'phone'], default='pc', help="Wähle 'pc' für Desktop oder 'phone' für Handy-Webserver")
|
|
120
|
+
args = parser.parse_args()
|
|
121
|
+
|
|
122
|
+
if args.mode == 'pc':
|
|
123
|
+
root = tk.Tk()
|
|
124
|
+
app = LocalSuperVisionApp(root)
|
|
125
|
+
root.mainloop()
|
|
126
|
+
elif args.mode == 'phone':
|
|
127
|
+
run_phone_mode()
|
|
128
|
+
|
|
129
|
+
if __name__ == '__main__':
|
|
130
|
+
cli()
|