专栏名称: 机器学习算法与Python实战
长期跟踪关注统计学、数据挖掘、机器学习算法、深度学习、人工智能技术与行业发展动态,分享Python、机器学习等技术文章。回复机器学习有惊喜资料。
目录
相关文章推荐
中国交建  ·  奋进之春丨中交集团这些项目迎来重大进展③ ·  1小时前  
中国铁建  ·  中国铁建召开总部部门2024年度绩效考核现场 ... ·  5 小时前  
中国交建  ·  中交集团召开战略系统2025年重点工作部署会 ·  2 天前  
中国交建  ·  解锁工程加速度的“安全密码” ·  3 天前  
51好读  ›  专栏  ›  机器学习算法与Python实战

GPT-4 Claude 3 Gemini Pro对决,还是GPT-4胜一筹

机器学习算法与Python实战  · 公众号  ·  · 2024-03-08 11:31

正文

大模型战力排行榜

这两天折腾了两个Mac上的小应用,一个是从视频抽取音频,一个是短视频转Gif。

功能分别是将视频文件/文件夹拖拽到图标上,自动抽取视频中的音频文件;将短视频拖拽到图标上,自动转成Gif格式并保存到桌面。

这件事必然交给大模型来做最合适了,为了对比,我同时让GPT-4、Claude 3 Sonnet、Gemini去帮我生成代码。

以视频转Gif为例,我的Prompt是

我想在mac上将mp4格式的短视频转成gif,要求GIF的尺寸与原视频保持一致。我希望你能用Apple script实现它,并另存为application,我想直接讲视频拖拽到这个app的图标上就自动完成gif转换,请给我具体代码。

结果只有GPT-4给出的代码非常精简、步骤详实且没有语法错误

这个脚本之需要将其中ffmpeg的位置修改为自己电脑上的实际位置即可

我对Apple script一无所知,所以没有深究其他大模型给出代码的实际问题,只知道在运行时会报出语法错误。

Claude 3 、Gemini,mistral,还有不点名的国产大模型,均败北。

附件

顺便分享这三个小玩意儿的代码

Mp4转Gif:

on open of theFiles
    set desktopPath to POSIX path of (path to desktop)
    
    repeat with aFile in theFiles
        set filePath to POSIX path of aFile
        set fileName to do shell script "basename " & quoted form of filePath
        set destPath to desktopPath & text 1 thru -5 of fileName & ".gif"
        
        set shellCommand to "/opt/homebrew/bin/ffmpeg -i " & quoted form of filePath & " -vf \"fps=10,scale=-1:-1:flags=lanczos\" -c:v gif -f gif " & quoted form of destPath
        
        do shell script shellCommand
    end repeat
end open

Video抽取音频

on open of theFiles
    set desktopPath to POSIX path of (path to desktop)
    
    repeat with aFile in theFiles
        set filePath to POSIX path of aFile
        set fileName to do shell script "basename " & quoted form of filePath
        set destPath to desktopPath & text 1 thru -5 of fileName & ".gif"
        
        set shellCommand to "/opt/homebrew/bin/ffmpeg -i " & quoted form of filePath & " -vf \"fps=10,scale=-1:-1:flags=lanczos\" -c:v gif -f gif " & quoted form of destPath
        
        do shell script shellCommand
    end repeat
end open

webp转PNG

on open of theFiles
 repeat with aFile in theFiles
  set filePath to POSIX path of aFile if filePath ends with "-webp" then
  set outputPath to POSIX path of (path to desktop folder) & (do shell scri do shell script "sips-s format      png " & quoted form of filePath & " --out
end if end repeat
end open

使用方法

  1. 打开“脚本编辑器”(Script Editor)应用程序。
  2. 粘贴上述AppleScript代码到脚本编辑器中。
  3. 在脚本编辑器中,选择“文件” > “导出...”。
  4. 在“导出”对话框中,选择文件格式为“应用程序”,给你的应用程序命名,然后保存。
  5. 确保在“选项”下勾选了“保留运行时的父脚本”。

GPT-4又帮了我一个小忙







请到「今天看啥」查看全文