jbilcke-hf HF staff commited on
Commit
39166f8
·
1 Parent(s): 30a90be

reducing volume of logs

Browse files
src/analysis/analyzeImageWithIDEFICS.mts CHANGED
@@ -14,7 +14,7 @@ export async function analyzeImage(src: string, prompt: string): Promise<string>
14
  hf_token: `${process.env.VC_HF_API_TOKEN}` as any
15
  })
16
 
17
- console.log("/analyzeImage: calling api.predict(6, ...)")
18
 
19
  /*
20
  the chat history has this format:
 
14
  hf_token: `${process.env.VC_HF_API_TOKEN}` as any
15
  })
16
 
17
+ // console.log("/analyzeImage: calling api.predict(6, ...)")
18
 
19
  /*
20
  the chat history has this format:
src/production/renderImage.mts CHANGED
@@ -13,7 +13,7 @@ export async function renderImage(
13
  ? generateImageSDXL360AsBase64
14
  : generateImageSDXLAsBase64
15
 
16
- console.log(`going to generate an image using ${request.projection || "default (cartesian)"} projection`)
17
 
18
  const params = {
19
  positivePrompt: request.prompt,
@@ -24,21 +24,21 @@ export async function renderImage(
24
  height: request.height
25
  }
26
 
27
- console.log(`calling generateImageAsBase64 with: `, JSON.stringify(params, null, 2))
28
 
29
 
30
  // first we generate a quick low quality version
31
  try {
32
  response.assetUrl = await generateImageAsBase64(params)
33
- console.log("successful generation!", response.assetUrl.slice(0, 30))
34
  if (!response.assetUrl?.length) {
35
  throw new Error(`the generated image is empty`)
36
  }
37
  } catch (err) {
38
- console.error(`failed to render.. but let's try again!`)
39
  try {
40
  response.assetUrl = await generateImageAsBase64(params)
41
- console.log("successful generation!", response.assetUrl.slice(0, 30))
42
  if (!response.assetUrl?.length) {
43
  throw new Error(`the generated image is empty`)
44
  }
 
13
  ? generateImageSDXL360AsBase64
14
  : generateImageSDXLAsBase64
15
 
16
+ // console.log(`going to generate an image using ${request.projection || "default (cartesian)"} projection`)
17
 
18
  const params = {
19
  positivePrompt: request.prompt,
 
24
  height: request.height
25
  }
26
 
27
+ // console.log(`calling generateImageAsBase64 with: `, JSON.stringify(params, null, 2))
28
 
29
 
30
  // first we generate a quick low quality version
31
  try {
32
  response.assetUrl = await generateImageAsBase64(params)
33
+ // console.log("successful generation!", response.assetUrl.slice(0, 30))
34
  if (!response.assetUrl?.length) {
35
  throw new Error(`the generated image is empty`)
36
  }
37
  } catch (err) {
38
+ // console.error(`failed to render.. but let's try again!`)
39
  try {
40
  response.assetUrl = await generateImageAsBase64(params)
41
+ // console.log("successful generation!", response.assetUrl.slice(0, 30))
42
  if (!response.assetUrl?.length) {
43
  throw new Error(`the generated image is empty`)
44
  }
src/production/renderImageSegmentation.mts CHANGED
@@ -16,42 +16,42 @@ export async function renderImageSegmentation(
16
  const actionnables = Array.isArray(request.actionnables) ? request.actionnables : []
17
 
18
  if (actionnables.length > 0) {
19
- console.log("we have some actionnables:", actionnables)
20
 
21
  const tmpImageFilePath = path.join(tmpDir, `${uuidv4()}.png`)
22
 
23
  // console.log("beginning:", imageBase64.slice(0, 100))
24
  await writeBase64ToFile(response.assetUrl, tmpImageFilePath)
25
- console.log("wrote the image to ", tmpImageFilePath)
26
 
27
  if (!tmpImageFilePath) {
28
- console.error("failed to segment the image")
29
  response.error = "failed to segment the image"
30
  response.status = "error"
31
  } else {
32
- console.log("got the first frame! segmenting..")
33
  try {
34
  const result = await segmentImage(tmpImageFilePath, actionnables, request.width, request.height)
35
  response.maskUrl = result.maskUrl
36
  response.segments = result.segments
37
 
38
- console.log(`it worked the first time! got ${response.segments.length} segments`)
39
  } catch (err) {
40
- console.log("this takes too long :/ trying another server..")
41
  try {
42
  const result = await segmentImage(tmpImageFilePath, actionnables, request.width, request.height)
43
  response.maskUrl = result.maskUrl
44
  response.segments = result.segments
45
 
46
- console.log(`it worked the second time! got ${response.segments.length} segments`)
47
  } catch (err) {
48
- console.log("trying one last time, on a 3rd server..")
49
  try {
50
  const result = await segmentImage(tmpImageFilePath, actionnables, request.width, request.height)
51
  response.maskUrl = result.maskUrl
52
  response.segments = result.segments
53
 
54
- console.log(`it worked the third time! got ${response.segments.length} segments`)
55
  } catch (err) {
56
  console.log("yeah, all servers are busy it seems.. aborting")
57
  response.error = "all servers are busy"
@@ -61,7 +61,7 @@ export async function renderImageSegmentation(
61
  }
62
  }
63
  } else {
64
- console.log("no actionnables: just returning the image, then")
65
  }
66
 
67
  return response
 
16
  const actionnables = Array.isArray(request.actionnables) ? request.actionnables : []
17
 
18
  if (actionnables.length > 0) {
19
+ // console.log("we have some actionnables:", actionnables)
20
 
21
  const tmpImageFilePath = path.join(tmpDir, `${uuidv4()}.png`)
22
 
23
  // console.log("beginning:", imageBase64.slice(0, 100))
24
  await writeBase64ToFile(response.assetUrl, tmpImageFilePath)
25
+ // console.log("wrote the image to ", tmpImageFilePath)
26
 
27
  if (!tmpImageFilePath) {
28
+ // console.error("failed to segment the image")
29
  response.error = "failed to segment the image"
30
  response.status = "error"
31
  } else {
32
+ // console.log("got the first frame! segmenting..")
33
  try {
34
  const result = await segmentImage(tmpImageFilePath, actionnables, request.width, request.height)
35
  response.maskUrl = result.maskUrl
36
  response.segments = result.segments
37
 
38
+ // console.log(`it worked the first time! got ${response.segments.length} segments`)
39
  } catch (err) {
40
+ // console.log("this takes too long :/ trying another server..")
41
  try {
42
  const result = await segmentImage(tmpImageFilePath, actionnables, request.width, request.height)
43
  response.maskUrl = result.maskUrl
44
  response.segments = result.segments
45
 
46
+ // console.log(`it worked the second time! got ${response.segments.length} segments`)
47
  } catch (err) {
48
+ // console.log("trying one last time, on a 3rd server..")
49
  try {
50
  const result = await segmentImage(tmpImageFilePath, actionnables, request.width, request.height)
51
  response.maskUrl = result.maskUrl
52
  response.segments = result.segments
53
 
54
+ // console.log(`it worked the third time! got ${response.segments.length} segments`)
55
  } catch (err) {
56
  console.log("yeah, all servers are busy it seems.. aborting")
57
  response.error = "all servers are busy"
 
61
  }
62
  }
63
  } else {
64
+ // console.log("no actionnables: just returning the image, then")
65
  }
66
 
67
  return response
src/production/renderImageUpscaling.mts CHANGED
@@ -9,12 +9,12 @@ export async function renderImageUpscaling(
9
  try {
10
  // note: this converts a base64 PNG to a base64 JPG (which is good, actually!)
11
  response.assetUrl = await upscaleImage(response.assetUrl, request.upscalingFactor)
12
- console.log(`upscaling worked on the first try!`)
13
  } catch (err) {
14
- console.error(`upscaling failed the first time.. let's try again..`)
15
  try {
16
  response.assetUrl = await upscaleImage(response.assetUrl, request.upscalingFactor)
17
- console.log(`upscaling worked on the second try!`)
18
  } catch (err) {
19
  console.error(`upscaling failed on the second attempt.. let's keep the low-res image then :|`)
20
  // no need to log a catastrophic failure here, since we still have the original (low-res image)
 
9
  try {
10
  // note: this converts a base64 PNG to a base64 JPG (which is good, actually!)
11
  response.assetUrl = await upscaleImage(response.assetUrl, request.upscalingFactor)
12
+ // console.log(`upscaling worked on the first try!`)
13
  } catch (err) {
14
+ // console.error(`upscaling failed the first time.. let's try again..`)
15
  try {
16
  response.assetUrl = await upscaleImage(response.assetUrl, request.upscalingFactor)
17
+ // console.log(`upscaling worked on the second try!`)
18
  } catch (err) {
19
  console.error(`upscaling failed on the second attempt.. let's keep the low-res image then :|`)
20
  // no need to log a catastrophic failure here, since we still have the original (low-res image)
src/production/renderPipeline.mts CHANGED
@@ -16,19 +16,19 @@ export async function renderPipeline(request: RenderRequest, response: RenderedS
16
  const renderSegmentation = isVideo ? renderVideoSegmentation : renderImageSegmentation
17
 
18
  if (isVideo) {
19
- console.log(`rendering a video..`)
20
  } else {
21
- console.log(`rendering an image..`)
22
  }
23
 
24
  try {
25
  await renderContent(request, response)
26
  } catch (err) {
27
- console.log(`renderContent() failed, trying a 2nd time..`)
28
  try {
29
  await renderContent(request, response)
30
  } catch (err2) {
31
- console.log(`renderContent() failed, trying a 3th time..`)
32
  await renderContent(request, response)
33
  }
34
  }
@@ -75,16 +75,16 @@ export async function renderPipeline(request: RenderRequest, response: RenderedS
75
  response.error = ""
76
 
77
  if (!request.cache || request.cache === "ignore") {
78
- console.log("client asked to not use the cache in the rendering pipeline")
79
  return
80
  }
81
 
82
- console.log("client asked this for cache: "+request.cache)
83
 
84
  try {
85
  // since the request is now completed we cache it
86
  await saveRenderedSceneToCache(request, response)
87
- console.log("successfully saved to cache")
88
 
89
  // we don't really need to remove it from the in-memory cache
90
  // (the cache queue in src/production/renderScene.mts)
 
16
  const renderSegmentation = isVideo ? renderVideoSegmentation : renderImageSegmentation
17
 
18
  if (isVideo) {
19
+ // console.log(`rendering a video..`)
20
  } else {
21
+ // console.log(`rendering an image..`)
22
  }
23
 
24
  try {
25
  await renderContent(request, response)
26
  } catch (err) {
27
+ // console.log(`renderContent() failed, trying a 2nd time..`)
28
  try {
29
  await renderContent(request, response)
30
  } catch (err2) {
31
+ // console.log(`renderContent() failed, trying a 3th time..`)
32
  await renderContent(request, response)
33
  }
34
  }
 
75
  response.error = ""
76
 
77
  if (!request.cache || request.cache === "ignore") {
78
+ // console.log("client asked to not use the cache in the rendering pipeline")
79
  return
80
  }
81
 
82
+ // console.log("client asked this for cache: "+request.cache)
83
 
84
  try {
85
  // since the request is now completed we cache it
86
  await saveRenderedSceneToCache(request, response)
87
+ // console.log("successfully saved to cache")
88
 
89
  // we don't really need to remove it from the in-memory cache
90
  // (the cache queue in src/production/renderScene.mts)
src/production/renderScene.mts CHANGED
@@ -33,7 +33,7 @@ export async function renderScene(request: RenderRequest): Promise<RenderedScene
33
  // we start it, but we do not await for the response
34
  renderPipeline(request, response)
35
 
36
- console.log("renderScene: yielding the scene", response)
37
  return response
38
  }
39
 
 
33
  // we start it, but we do not await for the response
34
  renderPipeline(request, response)
35
 
36
+ // console.log("renderScene: yielding the scene", response)
37
  return response
38
  }
39
 
src/production/renderVideoSegmentation.mts CHANGED
@@ -13,20 +13,20 @@ export async function renderVideoSegmentation(
13
  const actionnables = Array.isArray(request.actionnables) ? request.actionnables : []
14
 
15
  if (actionnables.length > 0) {
16
- console.log("we have some actionnables:", actionnables)
17
  if (request.segmentation === "firstframe") {
18
- console.log("going to grab the first frame")
19
  const tmpVideoFilePath = await downloadFileToTmp(response.assetUrl, `${uuidv4()}`)
20
- console.log("downloaded the first frame to ", tmpVideoFilePath)
21
  const firstFrameFilePath = await getFirstVideoFrame(tmpVideoFilePath)
22
- console.log("downloaded the first frame to ", firstFrameFilePath)
23
 
24
  if (!firstFrameFilePath) {
25
- console.error("failed to get the image")
26
  response.error = "failed to segment the image"
27
  response.status = "error"
28
  } else {
29
- console.log("got the first frame! segmenting..")
30
  const result = await segmentImage(firstFrameFilePath, actionnables, request.width, request.height)
31
  response.maskUrl = result.maskUrl
32
  response.segments = result.segments
 
13
  const actionnables = Array.isArray(request.actionnables) ? request.actionnables : []
14
 
15
  if (actionnables.length > 0) {
16
+ // console.log("we have some actionnables:", actionnables)
17
  if (request.segmentation === "firstframe") {
18
+ // console.log("going to grab the first frame")
19
  const tmpVideoFilePath = await downloadFileToTmp(response.assetUrl, `${uuidv4()}`)
20
+ // console.log("downloaded the first frame to ", tmpVideoFilePath)
21
  const firstFrameFilePath = await getFirstVideoFrame(tmpVideoFilePath)
22
+ // console.log("downloaded the first frame to ", firstFrameFilePath)
23
 
24
  if (!firstFrameFilePath) {
25
+ // console.error("failed to get the image")
26
  response.error = "failed to segment the image"
27
  response.status = "error"
28
  } else {
29
+ // console.log("got the first frame! segmenting..")
30
  const result = await segmentImage(firstFrameFilePath, actionnables, request.width, request.height)
31
  response.maskUrl = result.maskUrl
32
  response.segments = result.segments