enzostvs HF staff commited on
Commit
dc7c6b2
·
1 Parent(s): 0307ca7
src/routes/api/scrap-models/+server.ts CHANGED
@@ -13,7 +13,7 @@ export async function POST({ request }) {
13
  }, { status: 401 });
14
  }
15
 
16
- const response = await fetch(`https://huggingface.co/api/models?limit=5000&filter=lora%2Cdiffusers&sort=createdAt&full=true&config=true`)
17
  const responseData = await response.json();
18
 
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -31,17 +31,14 @@ export async function POST({ request }) {
31
  continue
32
  }
33
  const imageRegex = /!\[.*\]\((.*)\)/
34
- const image = readme.match(imageRegex)?.[1]
35
 
36
  if (!image) {
37
  continue
38
  }
 
39
  if (image.startsWith("http")) model.image = image
40
- else if (image.includes(model.id)) {
41
- const path = image.split("/")
42
- model.image = `https://huggingface.co/${model.id}/raw/main/${path[path.length - 1]}`
43
- }
44
- else model.image = `https://huggingface.co/${model.id}/raw/main/${image.replace("./", "")}`
45
  }
46
 
47
  await prisma.model.create({
 
13
  }, { status: 401 });
14
  }
15
 
16
+ const response = await fetch(`https://huggingface.co/api/models?limit=500&filter=lora%2Cdiffusers&sort=createdAt&full=true&config=true`)
17
  const responseData = await response.json();
18
 
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
 
31
  continue
32
  }
33
  const imageRegex = /!\[.*\]\((.*)\)/
34
+ let image = readme.match(imageRegex)?.[1]
35
 
36
  if (!image) {
37
  continue
38
  }
39
+ image = image.replace(///g, "/")
40
  if (image.startsWith("http")) model.image = image
41
+ else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
 
 
 
 
42
  }
43
 
44
  await prisma.model.create({