Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Feature : Deepfake #280

Merged
merged 2 commits into from
Nov 22, 2024
Merged

Add Feature : Deepfake #280

merged 2 commits into from
Nov 22, 2024

Conversation

AlexandrePrivat
Copy link
Contributor

No description provided.


score = 1 - extract(original_response,["type","deepfake"],None)
if score is None:
raise ProviderException(response.json())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to raise an exception wih the same message as for the deepfake video:

raise ProviderException("Deepfake score not found in response.")

"api_user": self.api_settings["api_user"],
"api_secret": self.api_settings["api_key"]}

response = requests.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually I like to try surround the requests call with a try/catch bloc in case of some exceptions like Timeout or ConnectionError, and than in case of an exception, raise a ProviderException. Same for the deepfake video

params=payload,
)

print(response.json())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe removing also the print

Comment on lines 83 to 106

payload = {
"models": "deepfake",
"api_user": self.api_settings["api_user"],
"api_secret": self.api_settings["api_key"],
"callback_url": self.webhook_url,
}

if file:
with open(file, 'rb') as video_file:
files = {'media': video_file}

response = requests.post(
f"{self.api_url}/video/check.json",
files=files,
data=payload,
)
elif file_url:
payload['stream_url'] = file_url

response = requests.get(
f"{self.api_url}/video/check.json",
params=payload,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can here maybe construct the requests parameters dynamically and than do only one request call depending on the method (get or post) using:

requests.request(method, url, **kwargs)

Here also adding a try/catch block

@DninoAdnane DninoAdnane merged commit 4141bb1 into edenai:master Nov 22, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants