Upload folder using huggingface_hub
Browse files- config.json +3 -3
- test_model.js +58 -0
config.json
CHANGED
|
@@ -43,9 +43,9 @@
|
|
| 43 |
"torch_dtype": "bfloat16",
|
| 44 |
"vocab_size": 102400
|
| 45 |
},
|
| 46 |
-
"model_type": "
|
| 47 |
"torch_dtype": "float16",
|
| 48 |
-
"transformers_version": "4.
|
| 49 |
"vision_config": {
|
| 50 |
"cls": "CLIPVisionTower",
|
| 51 |
"model_type": "vision",
|
|
@@ -57,7 +57,7 @@
|
|
| 57 |
}
|
| 58 |
},
|
| 59 |
"architectures": [
|
| 60 |
-
"
|
| 61 |
],
|
| 62 |
"use_cache": true,
|
| 63 |
"webgpu_compatible": true,
|
|
|
|
| 43 |
"torch_dtype": "bfloat16",
|
| 44 |
"vocab_size": 102400
|
| 45 |
},
|
| 46 |
+
"model_type": "multi_modality",
|
| 47 |
"torch_dtype": "float16",
|
| 48 |
+
"transformers_version": "4.36.0",
|
| 49 |
"vision_config": {
|
| 50 |
"cls": "CLIPVisionTower",
|
| 51 |
"model_type": "vision",
|
|
|
|
| 57 |
}
|
| 58 |
},
|
| 59 |
"architectures": [
|
| 60 |
+
"MultiModalityCausalLM"
|
| 61 |
],
|
| 62 |
"use_cache": true,
|
| 63 |
"webgpu_compatible": true,
|
test_model.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Janus Model Test Script
|
| 2 |
+
// Test if the model can be loaded successfully
|
| 3 |
+
|
| 4 |
+
import { AutoProcessor, MultiModalityCausalLM } from "@huggingface/transformers";
|
| 5 |
+
|
| 6 |
+
async function testJanusModel() {
|
| 7 |
+
console.log("Testing Janus Model Loading...");
|
| 8 |
+
|
| 9 |
+
const modelPath = + str(model_dir) + ;
|
| 10 |
+
|
| 11 |
+
try {
|
| 12 |
+
console.log("Loading processor...");
|
| 13 |
+
const processor = await AutoProcessor.from_pretrained(modelPath);
|
| 14 |
+
console.log("Processor loaded successfully");
|
| 15 |
+
|
| 16 |
+
console.log("Loading model...");
|
| 17 |
+
const model = await MultiModalityCausalLM.from_pretrained(modelPath, {
|
| 18 |
+
device: "webgpu",
|
| 19 |
+
dtype: "q4f16"
|
| 20 |
+
});
|
| 21 |
+
console.log("Model loaded successfully");
|
| 22 |
+
|
| 23 |
+
console.log("
|
| 24 |
+
SUCCESS! Model initialization complete");
|
| 25 |
+
console.log("Model is ready for inference");
|
| 26 |
+
|
| 27 |
+
return { model, processor };
|
| 28 |
+
|
| 29 |
+
} catch (error) {
|
| 30 |
+
console.error("Model loading failed:");
|
| 31 |
+
console.error(error);
|
| 32 |
+
|
| 33 |
+
// Try CPU fallback
|
| 34 |
+
console.log("
|
| 35 |
+
Trying CPU fallback...");
|
| 36 |
+
try {
|
| 37 |
+
const processor = await AutoProcessor.from_pretrained(modelPath);
|
| 38 |
+
const model = await MultiModalityCausalLM.from_pretrained(modelPath, {
|
| 39 |
+
device: "cpu"
|
| 40 |
+
});
|
| 41 |
+
console.log("CPU fallback successful");
|
| 42 |
+
return { model, processor };
|
| 43 |
+
} catch (cpuError) {
|
| 44 |
+
console.error("CPU fallback also failed:");
|
| 45 |
+
console.error(cpuError);
|
| 46 |
+
throw cpuError;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
// Run the test
|
| 52 |
+
testJanusModel()
|
| 53 |
+
.then(() => console.log("
|
| 54 |
+
Test completed successfully"))
|
| 55 |
+
.catch(error => console.error("
|
| 56 |
+
Test failed:", error));
|
| 57 |
+
|
| 58 |
+
export { testJanusModel };
|