Spaces:
Sleeping
Sleeping
syurein
commited on
Commit
·
c1220a2
1
Parent(s):
6bd43d6
Fix-gitignore
Browse files- .gitignore +15 -0
- app.py +14 -14
- requirements.txt +4 -4
- templates/index.html +1 -1
.gitignore
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# Environments
|
7 |
+
aidentify/
|
8 |
+
llm_aidentify/
|
9 |
+
|
10 |
+
# Saved images
|
11 |
+
saved_images/
|
12 |
+
output_*.jpg
|
13 |
+
|
14 |
+
# Jupyter Notebook checkpoints
|
15 |
+
.ipynb_checkpoints/
|
app.py
CHANGED
@@ -297,22 +297,25 @@ async def llm_to_process_image_simple_auto(risk_level, image_path, point1, point
|
|
297 |
debug_image_name = "masked_image.jpg" # デバッグ画像名を具体的に
|
298 |
debug_image_path = os.path.join("./saved_images", debug_image_name)
|
299 |
|
300 |
-
# 非同期メソッドをawaitで呼び出す
|
301 |
-
response = Objectdetector.detect_auto(image_path)
|
302 |
-
print(f"削除対象オブジェクト: {response['objects_to_remove']}")
|
303 |
-
Objectdetector.prompt_objects = response["objects_to_remove"]
|
304 |
-
|
305 |
# 個人情報流出に関する事例を検索し、クリーンなコンテンツを取得
|
306 |
-
scraper = WebScraper(headless=
|
307 |
-
# ここでasyncio.run()は不要。単にawaitする
|
308 |
personal_breach_docs = await scraper.get_processed_documents(
|
309 |
search_query="個人情報流出 事例 SNS",
|
310 |
num_search_results=10
|
311 |
)
|
312 |
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
|
|
315 |
|
|
|
|
|
|
|
|
|
|
|
316 |
# 画像の読み込みとRGB変換
|
317 |
print(f"Objectdetector.prompt_objects: {Objectdetector.prompt_objects}")
|
318 |
image = cv2.imread(image_path)
|
@@ -325,8 +328,8 @@ async def llm_to_process_image_simple_auto(risk_level, image_path, point1, point
|
|
325 |
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
326 |
mask_llm = np.zeros(image.shape[:2], dtype=np.uint8)
|
327 |
|
328 |
-
#
|
329 |
-
llm_results =
|
330 |
print(f"LLM検出結果: {llm_results}")
|
331 |
|
332 |
for result in llm_results:
|
@@ -1180,6 +1183,3 @@ async def mosaic_faces(reference_image: UploadFile = File(...), test_image: Uplo
|
|
1180 |
async def read_root(request: Request):
|
1181 |
|
1182 |
return templates.TemplateResponse("index.html", {"request": request})
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
|
|
297 |
debug_image_name = "masked_image.jpg" # デバッグ画像名を具体的に
|
298 |
debug_image_path = os.path.join("./saved_images", debug_image_name)
|
299 |
|
|
|
|
|
|
|
|
|
|
|
300 |
# 個人情報流出に関する事例を検索し、クリーンなコンテンツを取得
|
301 |
+
scraper = WebScraper(headless=False)
|
|
|
302 |
personal_breach_docs = await scraper.get_processed_documents(
|
303 |
search_query="個人情報流出 事例 SNS",
|
304 |
num_search_results=10
|
305 |
)
|
306 |
|
307 |
+
# 取得したドキュメントを結合し、Objectdetectorのテキストとして設定
|
308 |
+
if personal_breach_docs:
|
309 |
+
# personal_breach_docsは辞書のリストなので、各辞書からコンテンツを取り出して結合します
|
310 |
+
all_content = "\n\n---\n\n".join([doc['cleaned_html_content'] for doc in personal_breach_docs])
|
311 |
+
Objectdetector.text = all_content
|
312 |
+
print(f"Webスクレイピングの結果をコンテキストとして設定しました。文字数: {len(all_content)}")
|
313 |
|
314 |
+
# Webスクレイピングの結果を資料として渡し、リスク分析を実行
|
315 |
+
response = Objectdetector.detect_auto(image_path)
|
316 |
+
print(f"削除対象オブジェクト: {response['objects_to_remove']}")
|
317 |
+
Objectdetector.prompt_objects = response["objects_to_remove"]
|
318 |
+
|
319 |
# 画像の読み込みとRGB変換
|
320 |
print(f"Objectdetector.prompt_objects: {Objectdetector.prompt_objects}")
|
321 |
image = cv2.imread(image_path)
|
|
|
328 |
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
329 |
mask_llm = np.zeros(image.shape[:2], dtype=np.uint8)
|
330 |
|
331 |
+
# LLMによるオブジェクト検出を実行
|
332 |
+
llm_results = Objectdetector.detect_objects(image_path)
|
333 |
print(f"LLM検出結果: {llm_results}")
|
334 |
|
335 |
for result in llm_results:
|
|
|
1183 |
async def read_root(request: Request):
|
1184 |
|
1185 |
return templates.TemplateResponse("index.html", {"request": request})
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
annotated-types==0.7.0
|
2 |
-
|
3 |
anyio==4.6.2.post1
|
4 |
certifi==2024.8.30
|
5 |
charset-normalizer==3.4.0
|
@@ -27,11 +27,11 @@ mpmath==1.3.0
|
|
27 |
nest-asyncio==1.6.0
|
28 |
networkx==3.4.2
|
29 |
numpy==1.26.4
|
30 |
-
|
31 |
opencv-python-headless==4.10.0.84
|
32 |
packaging==24.1
|
33 |
pandas==2.2.3
|
34 |
-
Pillow==9.5.0
|
35 |
psutil==6.1.0
|
36 |
py-cpuinfo==9.0.0
|
37 |
pycocotools==2.0.8
|
@@ -50,7 +50,7 @@ scikit-learn==1.5.2
|
|
50 |
scipy==1.14.1
|
51 |
seaborn==0.13.2
|
52 |
setuptools==75.3.0
|
53 |
-
simple-lama-inpainting==0.1.2
|
54 |
six==1.16.0
|
55 |
sniffio==1.3.1
|
56 |
starlette==0.41.2
|
|
|
1 |
annotated-types==0.7.0
|
2 |
+
|
3 |
anyio==4.6.2.post1
|
4 |
certifi==2024.8.30
|
5 |
charset-normalizer==3.4.0
|
|
|
27 |
nest-asyncio==1.6.0
|
28 |
networkx==3.4.2
|
29 |
numpy==1.26.4
|
30 |
+
|
31 |
opencv-python-headless==4.10.0.84
|
32 |
packaging==24.1
|
33 |
pandas==2.2.3
|
34 |
+
Pillow==9.5.0
|
35 |
psutil==6.1.0
|
36 |
py-cpuinfo==9.0.0
|
37 |
pycocotools==2.0.8
|
|
|
50 |
scipy==1.14.1
|
51 |
seaborn==0.13.2
|
52 |
setuptools==75.3.0
|
53 |
+
simple-lama-inpainting==0.1.2
|
54 |
six==1.16.0
|
55 |
sniffio==1.3.1
|
56 |
starlette==0.41.2
|
templates/index.html
CHANGED
@@ -459,7 +459,7 @@
|
|
459 |
hideLoadingSpinner();
|
460 |
return;
|
461 |
}
|
462 |
-
processImageRequest(formData, "
|
463 |
}
|
464 |
function processFaceImage() {
|
465 |
if (!resizedImageBlob2 || !faceImageBlob) {
|
|
|
459 |
hideLoadingSpinner();
|
460 |
return;
|
461 |
}
|
462 |
+
processImageRequest(formData, "http://localhost:7860" + apiEndpoint);
|
463 |
}
|
464 |
function processFaceImage() {
|
465 |
if (!resizedImageBlob2 || !faceImageBlob) {
|