Spaces:
Runtime error
Runtime error
LPX
commited on
Commit
·
737fdca
1
Parent(s):
7cd1bf7
feat: enhance predict function with detailed docstring and add queue to demo interface
Browse files
app.py
CHANGED
|
@@ -532,6 +532,22 @@ detection_model_eval_playground = gr.Interface(
|
|
| 532 |
|
| 533 |
|
| 534 |
def predict(img):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 535 |
client = Client("aiwithoutborders-xyz/OpenSight-Community-Forensics-Preview")
|
| 536 |
client.view_api()
|
| 537 |
result = client.predict(
|
|
@@ -697,6 +713,7 @@ demo = gr.TabbedInterface(
|
|
| 697 |
|
| 698 |
# Add live update for the logs textbox
|
| 699 |
# demo.load(get_captured_logs, None, demo.outputs[8], every=1)
|
|
|
|
| 700 |
|
| 701 |
if __name__ == "__main__":
|
| 702 |
demo.launch(mcp_server=True)
|
|
|
|
| 532 |
|
| 533 |
|
| 534 |
def predict(img):
|
| 535 |
+
"""
|
| 536 |
+
Predicts whether an image is AI-generated or real using the SOTA Community Forensics model.
|
| 537 |
+
|
| 538 |
+
Args:
|
| 539 |
+
img (str): Path to the input image file to analyze.
|
| 540 |
+
|
| 541 |
+
Returns:
|
| 542 |
+
dict: A dictionary containing:
|
| 543 |
+
- 'Fake Probability' (float): Probability score between 0 and 1 indicating likelihood of being AI-generated
|
| 544 |
+
- 'Result Description' (str): Human-readable description of the prediction result
|
| 545 |
+
|
| 546 |
+
Example:
|
| 547 |
+
>>> result = predict("path/to/image.jpg")
|
| 548 |
+
>>> print(result)
|
| 549 |
+
{'Fake Probability': 0.002, 'Result Description': 'The image is likely real.'}
|
| 550 |
+
"""
|
| 551 |
client = Client("aiwithoutborders-xyz/OpenSight-Community-Forensics-Preview")
|
| 552 |
client.view_api()
|
| 553 |
result = client.predict(
|
|
|
|
| 713 |
|
| 714 |
# Add live update for the logs textbox
|
| 715 |
# demo.load(get_captured_logs, None, demo.outputs[8], every=1)
|
| 716 |
+
demo.queue(max_size=4)
|
| 717 |
|
| 718 |
if __name__ == "__main__":
|
| 719 |
demo.launch(mcp_server=True)
|