Skip to content

Commit

Permalink
move code around
Browse files Browse the repository at this point in the history
  • Loading branch information
sfomuseumbot committed Aug 30, 2024
1 parent e63aeb3 commit b69a2b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions process.go → prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import (
"github.com/whosonfirst/go-dedupe/embeddings"
)

type ProcessResult struct {
type PrepareResult struct {
Image image.Image
Embeddings []float32
}

func Process(ctx context.Context, emb embeddings.Embedder, r io.ReadSeeker) (*ProcessResult, error) {
func Prepare(ctx context.Context, emb embeddings.Embedder, r io.ReadSeeker) (*PrepareResult, error) {

t1 := time.Now()

defer func() {
slog.Debug("Time to process record", "time", time.Since(t1))
slog.Debug("Time to prepare record", "time", time.Since(t1))
}()

im, _, err := image.Decode(r)
Expand All @@ -33,13 +33,13 @@ func Process(ctx context.Context, emb embeddings.Embedder, r io.ReadSeeker) (*Pr
_, err = r.Seek(0, 0)

if err != nil {
return nil, err
return nil, fmt.Errorf("Failed to rewind reader, %w", err)
}

body, err := io.ReadAll(r)

if err != nil {
return nil, err
return nil, fmt.Errorf("Failed to read body, %w", err)
}

embeddings, err := emb.ImageEmbeddings32(ctx, body)
Expand All @@ -48,7 +48,7 @@ func Process(ctx context.Context, emb embeddings.Embedder, r io.ReadSeeker) (*Pr
return nil, fmt.Errorf("Failed to generate embeddings, %w", err)
}

pr := &ProcessResult{
pr := &PrepareResult{
Image: im,
Embeddings: embeddings,
}
Expand Down
2 changes: 1 addition & 1 deletion image.go → report/image.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package similar
package report

import (
"fmt"
Expand Down

0 comments on commit b69a2b6

Please sign in to comment.