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getElementById("output").innerHTML=
|
| 8 |
|
| 9 |
}
|
|
|
|
| 1 |
+
const keywords = {
|
| 2 |
+
|
| 3 |
+
image: [
|
| 4 |
+
"image",
|
| 5 |
+
"draw",
|
| 6 |
+
"paint",
|
| 7 |
+
"picture",
|
| 8 |
+
"photo",
|
| 9 |
+
"art",
|
| 10 |
+
"illustration",
|
| 11 |
+
"generate image"
|
| 12 |
+
],
|
| 13 |
+
|
| 14 |
+
translation: [
|
| 15 |
+
"translate",
|
| 16 |
+
"translation",
|
| 17 |
+
"convert language"
|
| 18 |
+
],
|
| 19 |
+
|
| 20 |
+
summary: [
|
| 21 |
+
"summarize",
|
| 22 |
+
"summary",
|
| 23 |
+
"shorten"
|
| 24 |
+
],
|
| 25 |
+
|
| 26 |
+
code: [
|
| 27 |
+
"code",
|
| 28 |
+
"python",
|
| 29 |
+
"java",
|
| 30 |
+
"cpp",
|
| 31 |
+
"c++",
|
| 32 |
+
"program"
|
| 33 |
+
],
|
| 34 |
+
|
| 35 |
+
speech: [
|
| 36 |
+
"speech",
|
| 37 |
+
"voice",
|
| 38 |
+
"audio"
|
| 39 |
+
],
|
| 40 |
+
|
| 41 |
+
ocr: [
|
| 42 |
+
"ocr",
|
| 43 |
+
"scan",
|
| 44 |
+
"extract text"
|
| 45 |
+
],
|
| 46 |
+
|
| 47 |
+
caption: [
|
| 48 |
+
"caption",
|
| 49 |
+
"describe image"
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
function detectModel(prompt){
|
| 55 |
+
|
| 56 |
+
prompt = prompt.toLowerCase();
|
| 57 |
+
|
| 58 |
+
for(let task in keywords){
|
| 59 |
+
|
| 60 |
+
for(let word of keywords[task]){
|
| 61 |
+
|
| 62 |
+
if(prompt.includes(word)){
|
| 63 |
+
|
| 64 |
+
return task;
|
| 65 |
+
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
return "text";
|
| 73 |
+
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
document.getElementById("generateBtn").onclick=function(){
|
| 77 |
|
| 78 |
+
const prompt=document.getElementById("prompt").value;
|
| 79 |
+
|
| 80 |
+
const task=detectModel(prompt);
|
| 81 |
+
|
| 82 |
+
let model="";
|
| 83 |
+
|
| 84 |
+
let output="";
|
| 85 |
+
|
| 86 |
+
switch(task){
|
| 87 |
+
|
| 88 |
+
case "image":
|
| 89 |
+
|
| 90 |
+
model="Stable Diffusion XL";
|
| 91 |
+
|
| 92 |
+
output="πΌ Image Generation Model Selected";
|
| 93 |
+
|
| 94 |
+
break;
|
| 95 |
+
|
| 96 |
+
case "translation":
|
| 97 |
+
|
| 98 |
+
model="NLLB-200";
|
| 99 |
+
|
| 100 |
+
output="π Translation Model Selected";
|
| 101 |
+
|
| 102 |
+
break;
|
| 103 |
+
|
| 104 |
+
case "summary":
|
| 105 |
+
|
| 106 |
+
model="BART";
|
| 107 |
+
|
| 108 |
+
output="π Summarization Model Selected";
|
| 109 |
+
|
| 110 |
+
break;
|
| 111 |
+
|
| 112 |
+
case "code":
|
| 113 |
+
|
| 114 |
+
model="Code Llama";
|
| 115 |
+
|
| 116 |
+
output="π» Code Generation Model Selected";
|
| 117 |
+
|
| 118 |
+
break;
|
| 119 |
+
|
| 120 |
+
case "speech":
|
| 121 |
+
|
| 122 |
+
model="Whisper";
|
| 123 |
+
|
| 124 |
+
output="π€ Speech Recognition Model Selected";
|
| 125 |
+
|
| 126 |
+
break;
|
| 127 |
+
|
| 128 |
+
case "ocr":
|
| 129 |
+
|
| 130 |
+
model="TrOCR";
|
| 131 |
+
|
| 132 |
+
output="π· OCR Model Selected";
|
| 133 |
+
|
| 134 |
+
break;
|
| 135 |
+
|
| 136 |
+
case "caption":
|
| 137 |
+
|
| 138 |
+
model="BLIP";
|
| 139 |
+
|
| 140 |
+
output="πΌ Image Captioning Model Selected";
|
| 141 |
+
|
| 142 |
+
break;
|
| 143 |
+
|
| 144 |
+
default:
|
| 145 |
+
|
| 146 |
+
model="Gemma 3";
|
| 147 |
+
|
| 148 |
+
output="π¬ Text Generation Model Selected";
|
| 149 |
+
|
| 150 |
+
}
|
| 151 |
|
| 152 |
+
document.getElementById("model").innerHTML=model;
|
| 153 |
|
| 154 |
+
document.getElementById("output").innerHTML=output;
|
| 155 |
|
| 156 |
}
|