Instead of $K=512$, I suppose that already
$$K=480$$
is enough (and perhaps the best possible choice).
I make use of a special property of the set
$$T:=\{0,1,2,4,7\},$$
namely, that every subset $X$ of $T$ is uniquely determined by the combination of its number of elements and the sum of its elements. Indeed, there is only one subset with $0$ elements; the $1$-element subsets clearly have different sums; the $2$-element subsets have respective sums $1,2,3,4,5,6,7,8,9,11$. The claim for $3$-, $4$-, $5$-element subsets follows because we know the sum and size of $T\setminus X$, which has $2$, $1$, or $0$ elements.
With positive integers $a$ and $b$ specified below, set
$$ A=\{a,2a,4a,8a,16a,K,K-b,K-2b,K-4b,K-7b\}.$$
If $X$ is any subset of $A$, then its element sum $w$ can be expressed as
$$ w = ra+sN-tb$$
where
$0\le r\le 31$, depending on which of the first five elements of $A$ belong to $X$; $0\le s\le 5$, depending on how many of the last five elements belong to $X$; $0\le t\le 14$, depending on which of the last five elements belong to $X$.
As we are given $w$, we obtain the bounds
$$\frac{w-31a}{K} \le s\le \frac{w+14b}{K}$$
This allows us to uniquely determine $s$, provided the bounds differ by less than $1$. For this reason and for additional reasons becoming clear in a moment, I choose
$$ a=1,\quad b=32,\quad\implies\frac{14b}{K}+\frac{31a}K=\frac{479}{480}<1.$$
Once we know $s$, we have
$$r=ra=w-sK+tb\equiv w\pmod {32},$$
which allows us to uniquely determine $r$ and ultimately $t$.
From the binary digits of $r$, we can clearly determine which of the first five elements are in $X$. For the other five elements, we use the special property of set $T$ described in the beginning -- clearly $K-bT=\{K,K-b,K-2b,K-4b,K-7b\}$ also has this property.
Summary
With the choices described above, set $A$ becomes
$$\{1,2,4,8,16,480, 448, 416, 352, 256\}$$
From each box, pick as many pearls as the different elements of $A$ specify.
Weigh these (giving $x$ grams) and compute the "mass defect"
$$w=59490-x$$
of the unknown subset $X$ of $A$.
Proceed as described above to find $r,s,t$ and ultimately the set $X$, and thereby precisely the "fake" boxes.