CoolFace
Apppublic

rafeaaa/AI-Forensics

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
app.py62 linesDownload Raw Back to root
1import streamlit as st2from transformers import pipeline3from PIL import Image4import os5 6st.set_page_config(page_title="AI Forensics Analyzer", layout="wide")7 8st.title("🕵️‍♂️ AI Forensics Analyzer")9st.write("تحليل جنائي ذكي للصور – Digital Forensics with Vision AI")10 11# -----------------------------12# 1) OCR / Image Captioning13# -----------------------------14st.header("📸 تحليل الصورة (Vision AI)")15 16uploaded_file = st.file_uploader("ارفع صورة للتحليل", type=["jpg", "jpeg", "png"])17 18if uploaded_file:19    image = Image.open(uploaded_file)20    st.image(image, caption="الصورة المدخلة", use_column_width=True)21 22    st.subheader("تحليل النص داخل الصورة (OCR)")23 24    try:25        ocr_model = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")26        result = ocr_model(image)[0]['generated_text']27        st.success(result)28    except Exception as e:29        st.error(f"خطأ في OCR: {e}")30 31# -----------------------------32# 2) Metadata Extraction33# -----------------------------34st.header("🧩 استخراج Metadata")35 36if uploaded_file:37    try:38        metadata = image.getexif()39        if metadata:40            st.json({T: metadata[T] for T in metadata})41        else:42            st.warning("لا توجد بيانات Metadata في هذه الصورة.")43    except Exception as e:44        st.error(f"خطأ في قراءة Metadata: {e}")45 46# -----------------------------47# 3) Summary48# -----------------------------49st.header("📝 تلخيص سريع للنتائج")50 51if uploaded_file:52    try:53        summarizer = pipeline("summarization", model="facebook/bart-large-cnn")54        text_to_summarize = f"""55        OCR Extracted Text: {result}56        Metadata: {str(metadata)}57        """58        summary = summarizer(text_to_summarize)[0]['summary_text']59        st.info(summary)60    except Exception as e:61        st.error(f"خطأ في التلخيص: {e}")62