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

缺少依赖 #5

Open
nnxiaod opened this issue Jul 12, 2024 · 2 comments
Open

缺少依赖 #5

nnxiaod opened this issue Jul 12, 2024 · 2 comments

Comments

@nnxiaod
Copy link

nnxiaod commented Jul 12, 2024

本地运行,报缺少模块,又安装了以下模块才正常运行:
pillow
addict
oss2
datasets==2.18.0
simplejson
sortedcontainers

抠图效果很好,感谢

@kkkkabsd
Copy link

我想问一下您该程序的运行顺序,配置好环境后是在upload中放如我想抠图的程序后 直接运行app.py这个程序嘛

@chino7913
Copy link

chino7913 commented Oct 4, 2024

我想问一下您该程序的运行顺序,配置好环境后是在upload中放如我想抠图的程序后 直接运行app.py这个程序嘛

啟動.py之後 打開預設服務 http://127.0.0.1:8000/
網址會有一個簡單的上傳表單讓你傳圖跟顯示結果
圖片也會生成在/output目錄中

另外可透過其他程式來post到這個服務ip, 如我這裡php範例

$server = "http://127.0.0.1:8000";
$image_path = "testimg/66974639.jpg";
$model_name = "people";  // people,universal

// 初始化 cURL
$ch = curl_init();

// 設置 cURL 請求
curl_setopt($ch, CURLOPT_URL, $server . '/matting');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

// 設置要上傳的文件和其他數據
$fields = [
    'image' => new CURLFile($image_path),  // 這裡使用 CURLFile 上傳文件
    'model' => $model_name
];
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

// 執行 cURL 請求
$response = curl_exec($ch);

// 檢查是否有錯誤
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    // 解析 JSON 響應
    $json_data = json_decode($response, true);
    if ($json_data) {
        $image_url = $json_data['result_image_url'];
        $mask_url = $json_data['mask_image_url'];
        
        echo "image_url: " . $server . $image_url . "<br>";
        echo "mask_url: " . $server . $mask_url . "<br>";
    } else {
        echo "Invalid JSON response.\n";
    }
}

// 關閉 cURL
curl_close($ch);

個人安裝過程除了需額外加一些模組還要注意版本
如果是modelscope 1.5.0 版本對 datasets 的依賴 只能datasets 2.7.0 到 2.8.0 之間

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

No branches or pull requests

3 participants