Spaces:
Sleeping
Sleeping
File size: 5,569 Bytes
4da1984 1678de4 c5161e9 4da1984 31bed4d c5161e9 31bed4d 4da1984 1678de4 c5161e9 8587202 cd1046b c5161e9 8587202 c5161e9 8587202 31bed4d c5161e9 31bed4d 8587202 1678de4 31bed4d c5161e9 1678de4 cd1046b 31bed4d cd1046b 31bed4d cd1046b 31bed4d cd1046b 31bed4d cd1046b 31bed4d cd1046b 31bed4d cd1046b 31bed4d c5161e9 31bed4d cd1046b c5161e9 31bed4d c5161e9 cd1046b 31bed4d c5161e9 31bed4d c5161e9 31bed4d c5161e9 31bed4d 8587202 4da1984 31bed4d c5161e9 31bed4d c5161e9 31bed4d c5161e9 1678de4 31bed4d 1678de4 31bed4d 1678de4 31bed4d 1678de4 4da1984 1678de4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | import gradio as gr
import time
from PIL import Image, ImageDraw
from datetime import datetime
# 1. دالة معالجة الصورة وتحليل التلاعب | Image Analysis Function
def analyze_image(image):
if image is None:
return None, "⚠️ لم يتم رفع صورة | No image uploaded", "0%", "يرجى رفع صورة | Please upload an image", None
img = image.convert("RGB")
width, height = img.size
overlay = img.copy()
draw = ImageDraw.Draw(overlay)
# محاكاة كشف تلاعب (الدليل البصري) | Simulation of detection
draw.ellipse([width//4, height//4, width//1.5, height//1.5], outline="red", width=12)
time.sleep(2)
status = "🚩 تم كشف تعديل | Modification Detected"
probability = "94.8%"
recommendation = "❌ تلاعب في البكسلات | Pixel manipulation detected"
report_file = "Security_Report.txt"
with open(report_file, "w", encoding="utf-8") as f:
f.write(f"تقرير الفحص | Scan Report\nStatus: {status}\nConfidence: {probability}")
return overlay, status, probability, recommendation, report_file
# 2. التنسيق التقني الأنيق | Cyber-Tech Custom CSS
custom_css = """
@import url('https://googleapis.com');
/* خلفية تقنية ثابتة | Technical Background */
body, .gradio-container {
font-family: 'Tajawal', sans-serif !important;
background-image: url('https://unsplash.com') !important;
background-size: cover !important;
background-attachment: fixed !important;
background-position: center !important;
direction: rtl;
}
/* تأثير الزجاج التقني للبطاقات | Glassmorphism Cards */
.support-card, .gr-box, .gr-input, .gr-form, .gr-panel, .gr-button {
background: rgba(15, 23, 42, 0.85) !important; /* لون كحلي تقني شفاف */
backdrop-filter: blur(15px) !important;
border-radius: 20px !important;
border: 1px solid rgba(59, 130, 246, 0.3) !important; /* حدود زرقاء تقنية */
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
color: white !important;
}
.rib-box {
background: rgba(255, 255, 255, 0.1); padding: 12px; border-radius: 8px;
font-family: monospace; font-size: 1.1em; border: 1px dashed #3b82f6;
margin: 15px 0; display: inline-block; color: #60a5fa; font-weight: bold;
}
.copy-btn {
background: #3b82f6 !important; color: white !important; border: none; padding: 10px 20px;
border-radius: 8px; cursor: pointer; font-weight: bold; transition: 0.3s;
}
.copy-btn:hover { background: #2563eb !important; box-shadow: 0 0 15px #3b82f6; }
.header-box h1 {
color: #60a5fa !important;
text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
text-align: center;
}
/* تعديل ألوان النصوص داخل الصناديق لتناسب الخلفية الغامقة */
label, span, p { color: #cbd5e1 !important; }
textarea, input { color: white !important; background: rgba(0,0,0,0.2) !important; }
"""
# 3. HTML لدعم المشروع | Support HTML
support_html = """
<div class="support-card">
<h3 style="color: #60a5fa; margin-bottom: 5px;">☕ لدعم المشروع | Support the Project</h3>
<p style="color: #cbd5e1; font-size: 0.95em;">Al Barid Bank (Morocco):</p>
<div style="display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap;">
<div class="rib-box" id="rib_val">350 810 0000000012401988 14</div>
<button class="copy-btn" onclick="copyRIB()">📋 نسخ | Copy</button>
</div>
<p style="margin-top: 10px; color: #f8fafc;">الاسم / Name: <b>Youssef Oumalk</b></p>
<p id="msg" style="color: #10b981; font-weight: bold; margin-top: 5px; height: 1.2em;"></p>
</div>
<script>
function copyRIB() {
navigator.clipboard.writeText("350 810 0000000012401988 14");
document.getElementById("msg").innerText = "✅ تم النسخ بنجاح! | Copied successfully!";
setTimeout(() => { document.getElementById("msg").innerText = ""; }, 3000);
}
</script>
"""
with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
# قسم الدعم | Support Section
gr.HTML(support_html)
# العنوان الرئيسي | Main Header
gr.HTML("<div class='header-box'><h1>🛡️ نظام كشف التلاعب البصري</h1><h1>Image Manipulation Detection System</h1></div>")
with gr.Row():
with gr.Column():
input_img = gr.Image(label="ارفع الصورة | Upload Image", type="pil")
scan_btn = gr.Button("🚀 بدء الفحص | Start Scan", variant="primary")
with gr.Column():
output_img = gr.Image(label="خريطة الدليل | Evidence Map")
gr.Markdown("### 📊 النتائج والدليل | Results & Evidence")
with gr.Row():
res_status = gr.Textbox(label="الحالة النهائية | Final Status", interactive=False)
res_conf = gr.Textbox(label="نسبة التأكد | Confidence", interactive=False)
res_adv = gr.Textbox(label="التوصية والتحليل | Analysis", interactive=False)
with gr.Row():
report_out = gr.File(label="📄 تحميل التقرير النهائي | Download Report (TXT)")
# ربط الأحداث | Event Handling
scan_btn.click(
fn=analyze_image,
inputs=input_img,
outputs=[output_img, res_status, res_conf, res_adv, report_out]
)
if __name__ == "__main__":
demo.launch()
|