Skip to content

Commit

Permalink
Merge pull request #9 from remyxai/v0.0.7
Browse files Browse the repository at this point in the history
reintroduce lazy download
  • Loading branch information
smellslikeml authored Dec 18, 2023
2 parents a6688be + 1669618 commit 63b4fa4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

2 changes: 2 additions & 0 deletions ffmperative/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

from . import tools as t
from .prompts import MAIN_PROMPT
from .utils import download_ffmp
from .tool_mapping import generate_tools_mapping
from .interpretor import evaluate, extract_function_calls

tools = generate_tools_mapping()

def run_local(prompt):
download_ffmp()
ffmp_path = pkg_resources.resource_filename('ffmperative', 'bin/ffmp')
safe_prompt = shlex.quote(prompt)
command = '{} -p "{}"'.format(ffmp_path, safe_prompt)
Expand Down
4 changes: 4 additions & 0 deletions ffmperative/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
3 changes: 0 additions & 3 deletions ffmperative/bin/ffmp

This file was deleted.

18 changes: 18 additions & 0 deletions ffmperative/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@

from pathlib import Path

def download_ffmp():
bin_dir = os.path.join(os.path.dirname(__file__), 'bin')
ffmp_path = os.path.join(bin_dir, 'ffmp')

# Create the 'bin/' directory if it does not exist
if not os.path.exists(bin_dir):
os.makedirs(bin_dir, exist_ok=True)

# Download ffmp file if it does not exist
if not os.path.exists(ffmp_path):
print("Downloading ffmp...")
model_url = "https://remyx.ai/assets/ffmperative/0.0.7/ffmp"
response = requests.get(model_url, stream=True)
with open(ffmp_path, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print("Download complete.")

def extract_and_encode_frame(video_path):
# Get the duration of the video
probe = ffmpeg.probe(video_path)
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
from setuptools import setup, find_packages
from setuptools.command.install import install

# read the contents of your README file
from pathlib import Path
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()


def read_requirements(file):
with open(file) as f:
return [line.strip() for line in f if line.strip() and not line.startswith('#')]
Expand All @@ -14,9 +17,6 @@ def read_requirements(file):
version="0.0.7",
packages=find_packages(),
include_package_data=True,
package_data={
'ffmperative': ['bin/ffmp'],
},
install_requires=read_requirements((this_directory / 'requirements.txt')),
entry_points={
"console_scripts": [
Expand Down

0 comments on commit 63b4fa4

Please sign in to comment.