Update app.py
Browse files
app.py
CHANGED
@@ -11,17 +11,19 @@ app = Flask(__name__)
|
|
11 |
upload_folder = os.path.join('static', 'uploads')
|
12 |
os.makedirs(upload_folder, exist_ok=True)
|
13 |
|
14 |
-
#
|
15 |
news_models = {
|
16 |
-
"
|
|
|
|
|
17 |
}
|
18 |
|
19 |
-
#
|
20 |
-
clip_model = CLIPModel.from_pretrained("openai/clip-vit-
|
21 |
-
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-
|
22 |
|
23 |
ai_image_models = {
|
24 |
-
"
|
25 |
}
|
26 |
|
27 |
# Image transformation pipeline
|
@@ -54,8 +56,9 @@ HTML_TEMPLATE = """
|
|
54 |
<textarea name="text" placeholder="Enter news text..." required></textarea>
|
55 |
<label for="model">Select Fake News Model:</label>
|
56 |
<select name="model" required>
|
57 |
-
<option value="
|
58 |
-
<option value="
|
|
|
59 |
</select>
|
60 |
<button type="submit">Detect News Authenticity</button>
|
61 |
</form>
|
@@ -115,7 +118,7 @@ def detect_image():
|
|
115 |
inputs = clip_processor(images=img, return_tensors="pt")
|
116 |
|
117 |
with torch.no_grad():
|
118 |
-
image_features = ai_image_models["
|
119 |
|
120 |
prediction = "AI-Generated" if torch.mean(image_features).item() > 0 else "Human-Created"
|
121 |
|
@@ -126,4 +129,3 @@ def detect_image():
|
|
126 |
|
127 |
if __name__ == "__main__":
|
128 |
app.run(host="0.0.0.0", port=7860) # Suitable for Hugging Face Spaces
|
129 |
-
|
|
|
11 |
upload_folder = os.path.join('static', 'uploads')
|
12 |
os.makedirs(upload_folder, exist_ok=True)
|
13 |
|
14 |
+
# Updated Fake News Detection Models
|
15 |
news_models = {
|
16 |
+
"mrm8488": pipeline("text-classification", model="mrm8488/bert-tiny-finetuned-fake-news-detection"),
|
17 |
+
"liam168": pipeline("text-classification", model="liam168/fake-news-bert-base-uncased"),
|
18 |
+
"distilbert": pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
|
19 |
}
|
20 |
|
21 |
+
# Updated Image Models for AI vs. Human Detection
|
22 |
+
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
23 |
+
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
24 |
|
25 |
ai_image_models = {
|
26 |
+
"clip-vit-base-patch32": clip_model
|
27 |
}
|
28 |
|
29 |
# Image transformation pipeline
|
|
|
56 |
<textarea name="text" placeholder="Enter news text..." required></textarea>
|
57 |
<label for="model">Select Fake News Model:</label>
|
58 |
<select name="model" required>
|
59 |
+
<option value="mrm8488">MRM8488 (BERT-Tiny)</option>
|
60 |
+
<option value="liam168">Liam168 (BERT)</option>
|
61 |
+
<option value="distilbert">DistilBERT (SST-2)</option>
|
62 |
</select>
|
63 |
<button type="submit">Detect News Authenticity</button>
|
64 |
</form>
|
|
|
118 |
inputs = clip_processor(images=img, return_tensors="pt")
|
119 |
|
120 |
with torch.no_grad():
|
121 |
+
image_features = ai_image_models["clip-vit-base-patch32"].get_image_features(**inputs)
|
122 |
|
123 |
prediction = "AI-Generated" if torch.mean(image_features).item() > 0 else "Human-Created"
|
124 |
|
|
|
129 |
|
130 |
if __name__ == "__main__":
|
131 |
app.run(host="0.0.0.0", port=7860) # Suitable for Hugging Face Spaces
|
|